Stream: jco

Topic: HTTP `RequestOptions` issue


view this post on Zulip Landon James (Mar 22 2024 at 17:28):

Was just testing my updates to add default timeouts to the RequestOptions object and noticed something weird. Although the timeout fields are given default values:

#connectTimeout = defaultHttpTimeoutMs * nanoToMilliConversion;
#firstByteTimeout = defaultHttpTimeoutMs * nanoToMilliConversion;
#betweenBytesTimeout = defaultHttpTimeoutMs * nanoToMilliConversion;

If not explicitly set in the Guest they are still undefined. Adding the following console.log:

firstByteTimeoutMs() {
    console.log("Value of #firstByteTimeout in firstByteTimeoutMs():", this.#firstByteTimeout)
    return this.#firstByteTimeout / nanoToMilliConversion;
}

Outputs:

Value of #firstByteTimeout in firstByteTimeoutMs(): undefined

And ends up throwing the following error:

TypeError: invalid variant tag value `undefined` (received `TypeError: Cannot mix BigInt and other types, use explicit conversions`) specified for `ErrorCode`

Maybe I am missing something with how Resources are created in the host language that causes those fields to never be set? I did try moving setting the values into a constructor() function, but got the same issue there.

Sorry I missed this, it was working in my initial implementation with the explicit undefined tests, but I missed this branch when testing the updates to the PR.

CC: @Guy Bedford

Adding a default timeout value of 600_000Ms to each of the HTTP timeouts to align with the defaults set by Wasmtime.

view this post on Zulip Guy Bedford (Mar 22 2024 at 18:11):

I also just saw this - have already included a fix for this in https://github.com/bytecodealliance/jco/pull/408

Updates to the latest toolchain dependencies including Wasmtime 19. Also includes some features and fixes: Refined error handling resolving #405. JS errors from imported JS functions now only coer...

view this post on Zulip Landon James (Mar 22 2024 at 18:23):

Didn't get it in before you merged, but did have one question about that change: https://github.com/bytecodealliance/jco/pull/408#discussion_r1536012195

Updates to the latest toolchain dependencies including Wasmtime 19. Also includes some features and fixes: Refined error handling resolving #405. JS errors from imported JS functions now only coer...

Last updated: Nov 22 2024 at 16:03 UTC