wasmer-js icon indicating copy to clipboard operation
wasmer-js copied to clipboard

Cannot convert null to a BigInt from poll_oneoff

Open jrandall opened this issue 3 years ago • 0 comments

poll_oneoff is throwing an exception from the line https://github.com/wasmerio/wasmer-js/blob/4c34bb0e584cc24036c3d6d7419550ff9c9ab502/packages/wasi/src/index.ts#L1402

const n = BigInt(now(clockid));
TypeError: Cannot convert null to a BigInt

The next lines appear to be an attempt to handle that situation by returning WASI_EINVAL if n is null:

if (n === null) {
                e = WASI_EINVAL;

However, it is too late at that point as if the result of now(clockid) is null, then BigInt is throwing a TypeError.

The code in clock_time_get appears to have a better check:

const n = now(clockId);
        if (n === null) {
          return WASI_EINVAL;
        }
        this.view.setBigUint64(time, BigInt(n), true);

jrandall avatar Jun 06 '21 11:06 jrandall