diff --git a/packages/preview2-shim/lib/nodejs/http.js b/packages/preview2-shim/lib/nodejs/http.js index 0cf830578..5d24bc9ac 100644 --- a/packages/preview2-shim/lib/nodejs/http.js +++ b/packages/preview2-shim/lib/nodejs/http.js @@ -176,26 +176,38 @@ const responseOutparamCreate = ResponseOutparam._create; delete ResponseOutparam._create; class RequestOptions { - #connectTimeoutMs; - #firstByteTimeoutMs; - #betweenBytesTimeoutMs; + #connectTimeout; + #firstByteTimeout; + #betweenBytesTimeout; + //The WASI Duration is nanoseconds, js timers are set with Ms. + //We store the data as nanos, but provide TimeoutMs methods for + //convenience in setting timers elsewhere + connectTimeout() { + return this.#connectTimeout; + } connectTimeoutMs() { - return this.#connectTimeoutMs; + return this.#connectTimeout / 1_000_000; + } + setConnectTimeout(duration) { + this.#connectTimeout = duration; } - setConnectTimeoutMs(duration) { - this.#connectTimeoutMs = duration; + firstByteTimeout() { + return this.#firstByteTimeout; } firstByteTimeoutMs() { - return this.#firstByteTimeoutMs; + return this.#firstByteTimeout / 1_000_000; + } + setFirstByteTimeout(duration) { + this.#firstByteTimeout = duration; } - setFirstByteTimeoutMs(duration) { - this.#firstByteTimeoutMs = duration; + betweenBytesTimeout() { + return this.#betweenBytesTimeout; } betweenBytesTimeoutMs() { - return this.#betweenBytesTimeoutMs; + return this.#betweenBytesTimeout / 1_000_000; } - setBetweenBytesTimeoutMs(duration) { - this.#betweenBytesTimeoutMs = duration; + setBetweenBytesTimeout(duration) { + this.#betweenBytesTimeout = duration; } }