diff --git a/package.json b/package.json index b5d18cf725..be7aa25973 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "lint": "bunx oxlint --config=oxlint.json --format=github src/js", "lint:fix": "oxlint --config oxlint.json --fix", "test": "node scripts/runner.node.mjs --exec-path ./build/debug/bun-debug", + "testleak": "BUN_DESTRUCT_VM_ON_EXIT=1 ASAN_OPTIONS=detect_leaks=1 LSAN_OPTIONS=malloc_context_size=100:print_suppressions=1:suppressions=$npm_config_local_prefix/test/leaksan.supp ./build/debug/bun-debug", "test:release": "node scripts/runner.node.mjs --exec-path ./build/release/bun", "banned": "bun test test/internal/ban-words.test.ts", "glob-sources": "bun scripts/glob-sources.mjs", diff --git a/packages/bun-uws/src/HttpParser.h b/packages/bun-uws/src/HttpParser.h index 8b6f26fcec..27664740d4 100644 --- a/packages/bun-uws/src/HttpParser.h +++ b/packages/bun-uws/src/HttpParser.h @@ -38,6 +38,11 @@ #include "ProxyParser.h" #include "QueryParser.h" #include "HttpErrors.h" + +#if defined(_WIN32) +#define strncasecmp _strnicmp +#endif + extern "C" size_t BUN_DEFAULT_MAX_HTTP_HEADER_SIZE; extern "C" int16_t Bun__HTTPMethod__from(const char *str, size_t len); @@ -232,11 +237,11 @@ namespace uWS TransferEncoding getTransferEncoding() { TransferEncoding te; - + if (!bf.mightHave("transfer-encoding")) { return te; } - + for (Header *h = headers; (++h)->key.length();) { if (h->key.length() == 17 && !strncmp(h->key.data(), "transfer-encoding", 17)) { // Parse comma-separated values, ensuring "chunked" is last if present @@ -244,33 +249,33 @@ namespace uWS size_t pos = 0; size_t lastTokenStart = 0; size_t lastTokenLen = 0; - + while (pos < value.length()) { // Skip leading whitespace while (pos < value.length() && (value[pos] == ' ' || value[pos] == '\t')) { pos++; } - + // Remember start of this token size_t tokenStart = pos; - + // Find end of token (until comma or end) while (pos < value.length() && value[pos] != ',') { pos++; } - + // Trim trailing whitespace from token size_t tokenEnd = pos; while (tokenEnd > tokenStart && (value[tokenEnd - 1] == ' ' || value[tokenEnd - 1] == '\t')) { tokenEnd--; } - + size_t tokenLen = tokenEnd - tokenStart; if (tokenLen > 0) { lastTokenStart = tokenStart; lastTokenLen = tokenLen; } - + // Move past comma if present if (pos < value.length() && value[pos] == ',') { pos++; @@ -283,12 +288,11 @@ namespace uWS } te.has = lastTokenLen > 0; - + // Check if the last token is "chunked" - if (lastTokenLen == 7 && !strncmp(value.data() + lastTokenStart, "chunked", 7)) [[likely]] { + if (lastTokenLen == 7 && strncasecmp(value.data() + lastTokenStart, "chunked", 7) == 0) [[likely]] { te.chunked = true; } - } } @@ -852,7 +856,7 @@ namespace uWS * ought to be handled as an error. */ const std::string_view contentLengthString = req->getHeader("content-length"); const auto contentLengthStringLen = contentLengthString.length(); - + /* Check Transfer-Encoding header validity and conflicts */ HttpRequest::TransferEncoding transferEncoding = req->getTransferEncoding(); @@ -962,7 +966,7 @@ public: data = (char *) dataToConsume.data(); length = (unsigned int) dataToConsume.length(); } else { - + // this is exactly the same as below! // todo: refactor this if (remainingStreamingBytes >= length) { diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index 5029e34823..972af6791d 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -81,6 +81,7 @@ function getNodeParallelTestTimeout(testPath) { return 90_000; } if (!isCI) return 60_000; // everything slower in debug mode + if (options["step"]?.includes("-asan-")) return 60_000; return 20_000; } @@ -1579,8 +1580,7 @@ function isJavaScriptTest(path) { * @returns {boolean} */ function isNodeTest(path) { - // Do not run node tests on macOS x64 in CI - // TODO: Unclear why we decided to do this? + // Do not run node tests on macOS x64 in CI, those machines are slow and expensive. if (isCI && isMacOS && isX64) { return false; } diff --git a/src/asan-config.c b/src/asan-config.c index 45cec7748d..e91944b28c 100644 --- a/src/asan-config.c +++ b/src/asan-config.c @@ -7,6 +7,11 @@ const char* __asan_default_options(void) // which breaks some JSC classes that have to be on the stack: // ASSERTION FAILED: Thread::currentSingleton().stack().contains(this) // cache/webkit-eda8b0fb4fb1aa23/include/JavaScriptCore/JSGlobalObjectInlines.h(63) : JSC::JSGlobalObject::GlobalPropertyInfo::GlobalPropertyInfo(const Identifier &, JSValue, unsigned int) - return "detect_stack_use_after_return=0"; + + // > https://clang.llvm.org/docs/AddressSanitizer.html#memory-leak-detection + // > The leak detection is turned on by default on Linux, and can be enabled using ASAN_OPTIONS=detect_leaks=1 on macOS. + // we want it to always be opt-in + + return "detect_stack_use_after_return=0:detect_leaks=0"; } #endif diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index f7c151f9b5..1c16f58b12 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -687,7 +687,7 @@ pub fn NewSocket(comptime ssl: bool) type { } pub fn getListener(this: *This, _: *jsc.JSGlobalObject) JSValue { - const handlers = this.getHandlers(); + const handlers = this.handlers orelse return .js_undefined; if (!handlers.is_server or this.socket.isDetached()) { return .js_undefined; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index cb53d50fbe..4853f5f847 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -566,12 +566,19 @@ pub fn NewServer(protocol_enum: enum { http, https }, development_kind: enum { d inspector_server_id: jsc.Debugger.DebuggerId = .init(0), pub const doStop = host_fn.wrapInstanceMethod(ThisServer, "stopFromJS", false); + pub const dispose = host_fn.wrapInstanceMethod(ThisServer, "disposeFromJS", false); + pub const doUpgrade = host_fn.wrapInstanceMethod(ThisServer, "onUpgrade", false); + pub const doPublish = host_fn.wrapInstanceMethod(ThisServer, "publish", false); + pub const doReload = onReload; + pub const doFetch = onFetch; + pub const doRequestIP = host_fn.wrapInstanceMethod(ThisServer, "requestIP", false); + pub const doTimeout = timeout; pub const UserRoute = struct { diff --git a/src/bun.js/bindings/ErrorCode.cpp b/src/bun.js/bindings/ErrorCode.cpp index 9aa66ed555..8fbaf2395c 100644 --- a/src/bun.js/bindings/ErrorCode.cpp +++ b/src/bun.js/bindings/ErrorCode.cpp @@ -2375,6 +2375,13 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_ZSTD_INVALID_PARAM, message)); } + case ErrorCode::ERR_SSL_NO_CIPHER_MATCH: { + auto err = createError(globalObject, ErrorCode::ERR_SSL_NO_CIPHER_MATCH, "No cipher match"_s); + err->putDirect(vm, Identifier::fromString(vm, "reason"_s), jsString(vm, WTF::String("no cipher match"_s))); + err->putDirect(vm, Identifier::fromString(vm, "library"_s), jsString(vm, WTF::String("SSL routines"_s))); + return JSC::JSValue::encode(err); + } + case ErrorCode::ERR_IPC_DISCONNECTED: return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_IPC_DISCONNECTED, "IPC channel is already disconnected"_s)); case ErrorCode::ERR_SERVER_NOT_RUNNING: @@ -2435,17 +2442,6 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_TLS_CERT_ALTNAME_FORMAT, "Invalid subject alternative name string"_s)); case ErrorCode::ERR_TLS_SNI_FROM_SERVER: return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_TLS_SNI_FROM_SERVER, "Cannot issue SNI from a TLS server-side socket"_s)); - case ErrorCode::ERR_SSL_NO_CIPHER_MATCH: { - auto err = createError(globalObject, ErrorCode::ERR_SSL_NO_CIPHER_MATCH, "No cipher match"_s); - - auto reason = JSC::jsString(vm, WTF::String("no cipher match"_s)); - err->putDirect(vm, Identifier::fromString(vm, "reason"_s), reason); - - auto library = JSC::jsString(vm, WTF::String("SSL routines"_s)); - err->putDirect(vm, Identifier::fromString(vm, "library"_s), library); - - return JSC::JSValue::encode(err); - } case ErrorCode::ERR_INVALID_URI: return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_INVALID_URI, "URI malformed"_s)); case ErrorCode::ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED: diff --git a/src/js/internal/http.ts b/src/js/internal/http.ts index 6ff8e9e4de..ecd92d4c4f 100644 --- a/src/js/internal/http.ts +++ b/src/js/internal/http.ts @@ -201,14 +201,6 @@ function validateMsecs(numberlike: any, field: string) { return numberlike; } -class ConnResetException extends Error { - constructor(msg) { - super(msg); - this.code = "ECONNRESET"; - this.name = "ConnResetException"; - } -} - const METHODS = [ "ACL", "BIND", @@ -487,7 +479,6 @@ function filterEnvForProxies(env) { } export { - ConnResetException, Headers, METHODS, STATUS_CODES, diff --git a/src/js/internal/shared.ts b/src/js/internal/shared.ts index afcf9c8930..defd073927 100644 --- a/src/js/internal/shared.ts +++ b/src/js/internal/shared.ts @@ -17,6 +17,9 @@ class NotImplementedError extends Error { // in the definition so that it isn't bundled unless used hideFromStack(NotImplementedError); } + get ["constructor"]() { + return Error; + } } function throwNotImplemented(feature: string, issue?: number, extra?: string): never { @@ -78,6 +81,9 @@ class ExceptionWithHostPort extends Error { this.port = port; } } + get ["constructor"]() { + return Error; + } } class NodeAggregateError extends AggregateError { @@ -85,12 +91,21 @@ class NodeAggregateError extends AggregateError { super(new SafeArrayIterator(errors), message); this.code = errors[0]?.code; } - get ["constructor"]() { return AggregateError; } } +class ConnResetException extends Error { + constructor(msg) { + super(msg); + this.code = "ECONNRESET"; + } + get ["constructor"]() { + return Error; + } +} + class ErrnoException extends Error { errno: number; syscall: string; @@ -106,7 +121,6 @@ class ErrnoException extends Error { this.code = code; this.syscall = syscall; } - get ["constructor"]() { return Error; } @@ -146,6 +160,7 @@ export default { warnNotImplementedOnce, ExceptionWithHostPort, NodeAggregateError, + ConnResetException, ErrnoException, once, getLazy, diff --git a/src/js/internal/streams/state.ts b/src/js/internal/streams/state.ts index 7bdb008096..7b8dee07f5 100644 --- a/src/js/internal/streams/state.ts +++ b/src/js/internal/streams/state.ts @@ -18,7 +18,7 @@ function highWaterMarkFrom( return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; } -function getDefaultHighWaterMark(objectMode?: boolean): number { +function getDefaultHighWaterMark(objectMode: boolean = false): number { return objectMode ? defaultHighWaterMarkObjectMode : defaultHighWaterMarkBytes; } diff --git a/src/js/node/_http_client.ts b/src/js/node/_http_client.ts index f3adf767a8..9cd64e9994 100644 --- a/src/js/node/_http_client.ts +++ b/src/js/node/_http_client.ts @@ -5,6 +5,7 @@ const { urlToHttpOptions } = require("internal/url"); const { isValidTLSArray } = require("internal/tls"); const { validateHeaderName } = require("node:_http_common"); const { getTimerDuration } = require("internal/timers"); +const { ConnResetException } = require("internal/shared"); const { kBodyChunks, abortedSymbol, @@ -41,7 +42,6 @@ const { reqSymbol, callCloseCallback, emitCloseNTAndComplete, - ConnResetException, } = require("internal/http"); const { globalAgent } = require("node:_http_agent"); diff --git a/src/js/node/_http_server.ts b/src/js/node/_http_server.ts index 6ffcaaf6ad..e40bb70bb5 100644 --- a/src/js/node/_http_server.ts +++ b/src/js/node/_http_server.ts @@ -3,6 +3,7 @@ const EventEmitter: typeof import("node:events").EventEmitter = require("node:ev const { Duplex, Stream } = require("node:stream"); const { _checkInvalidHeaderChar: checkInvalidHeaderChar } = require("node:_http_common"); const { validateObject, validateLinkHeaderValue, validateBoolean, validateInteger } = require("internal/validators"); +const { ConnResetException } = require("internal/shared"); const { isPrimary } = require("internal/cluster/isPrimary"); const { throwOnInvalidTLSArray } = require("internal/tls"); @@ -27,7 +28,6 @@ const { setIsNextIncomingMessageHTTPS, callCloseCallback, emitCloseNT, - ConnResetException, NodeHTTPResponseAbortEvent, STATUS_CODES, isTlsSymbol, diff --git a/src/js/node/net.ts b/src/js/node/net.ts index 1c50331347..9f28b94367 100644 --- a/src/js/node/net.ts +++ b/src/js/node/net.ts @@ -26,13 +26,12 @@ const EventEmitter = require("node:events"); let dns: typeof import("node:dns"); const normalizedArgsSymbol = Symbol("normalizedArgs"); -const { ExceptionWithHostPort } = require("internal/shared"); +const { ExceptionWithHostPort, ConnResetException, NodeAggregateError, ErrnoException } = require("internal/shared"); import type { Socket, SocketHandler, SocketListener } from "bun"; import type { Server as NetServer, Socket as NetSocket, ServerOpts } from "node:net"; import type { TLSSocket } from "node:tls"; const { kTimeout, getTimerDuration } = require("internal/timers"); const { validateFunction, validateNumber, validateAbortSignal, validatePort, validateBoolean, validateInt32, validateString } = require("internal/validators"); // prettier-ignore -const { NodeAggregateError, ErrnoException } = require("internal/shared"); const { isIPv4, isIPv6, isIP } = require("internal/net/isIP"); const ArrayPrototypeIncludes = Array.prototype.includes; @@ -2453,17 +2452,6 @@ function addServerAbortSignalOption(self, options) { } } -class ConnResetException extends Error { - constructor(msg) { - super(msg); - this.code = "ECONNRESET"; - } - - get ["constructor"]() { - return Error; - } -} - function emitListeningNextTick(self) { if (!self._handle) return; self.emit("listening"); diff --git a/src/js/node/worker_threads.ts b/src/js/node/worker_threads.ts index ac5f6320d6..c6d0633dde 100644 --- a/src/js/node/worker_threads.ts +++ b/src/js/node/worker_threads.ts @@ -4,7 +4,7 @@ declare const self: typeof globalThis; type WebWorker = InstanceType; const EventEmitter = require("node:events"); -const { Readable } = require("node:stream"); +const Readable = require("internal/streams/readable"); const { throwNotImplemented, warnNotImplementedOnce } = require("internal/shared"); const { diff --git a/test/harness.ts b/test/harness.ts index c9fff0a291..1cc1880b75 100644 --- a/test/harness.ts +++ b/test/harness.ts @@ -1874,12 +1874,10 @@ export function exampleSite(protocol: "https" | "http" = "https") { ca: protocol === "https" ? tls.cert : undefined, server, stop() { - server.stop(); + return server.stop(); }, - [Symbol.dispose]() { - try { - server.stop(); - } catch {} + async [Symbol.asyncDispose]() { + await server.stop(); }, }; } diff --git a/test/js/bun/io/bun-write.test.js b/test/js/bun/io/bun-write.test.js index 02ee7f7582..4294fe3ac1 100644 --- a/test/js/bun/io/bun-write.test.js +++ b/test/js/bun/io/bun-write.test.js @@ -273,7 +273,7 @@ const IS_UV_FS_COPYFILE_DISABLED = it("Bun.file -> Response", async () => { using tmpbase = tempDir("bun-file-to-response", {}); - using server = exampleSite("https"); + await using server = exampleSite("https"); // ensure the file doesn't already exist try { fs.unlinkSync(tmpbase + "fetch.js.out"); diff --git a/test/js/bun/test/parallel/test-http-7480-should-emit-continue-event.ts b/test/js/bun/test/parallel/test-http-7480-should-emit-continue-event.ts index 0eb4ba83fd..0ffbd599d7 100644 --- a/test/js/bun/test/parallel/test-http-7480-should-emit-continue-event.ts +++ b/test/js/bun/test/parallel/test-http-7480-should-emit-continue-event.ts @@ -3,7 +3,7 @@ import https from "node:https"; const { expect } = createTest(import.meta.path); // TODO: today we use a workaround to continue event, we need to fix it in the future. -using server = exampleSite(); +const server = exampleSite(); let receivedContinue = false; const req = https.request( server.url, diff --git a/test/js/bun/test/parallel/test-http-7480-should-not-emit-continue-event.ts b/test/js/bun/test/parallel/test-http-7480-should-not-emit-continue-event.ts index 0dcc06dc5c..ae630432cb 100644 --- a/test/js/bun/test/parallel/test-http-7480-should-not-emit-continue-event.ts +++ b/test/js/bun/test/parallel/test-http-7480-should-not-emit-continue-event.ts @@ -1,7 +1,7 @@ import { createTest, exampleSite } from "node-harness"; import https from "node:https"; const { expect } = createTest(import.meta.path); -using server = exampleSite(); +const server = exampleSite(); let receivedContinue = false; const req = https.request(server.url, { ca: server.ca, headers: { "accept-encoding": "identity" } }, res => { let data = ""; diff --git a/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-Client.ts b/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-Client.ts index c4a6a46a71..223dd710f7 100644 --- a/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-Client.ts +++ b/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-Client.ts @@ -7,8 +7,8 @@ const { expect } = createTest(import.meta.path); await using server = createServer((req, res) => { expect(req.url).toBe("/hello"); - res.writeHead(200); res.setHeader("content-encoding", "br"); + res.writeHead(200); const inputStream = new stream.Readable(); inputStream.push("Hello World"); diff --git a/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-fetch.ts b/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-fetch.ts index 4aae3f9919..430599c327 100644 --- a/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-fetch.ts +++ b/test/js/bun/test/parallel/test-http-can-send-brotli-from-Server-and-receive-with-fetch.ts @@ -7,8 +7,8 @@ const { expect } = createTest(import.meta.path); await using server = createServer((req, res) => { expect(req.url).toBe("/hello"); - res.writeHead(200); res.setHeader("content-encoding", "br"); + res.writeHead(200); const inputStream = new stream.Readable(); inputStream.push("Hello World"); diff --git a/test/js/bun/test/parallel/test-http-can-send-deflate-from-Server-and-receive-with-fetch.ts b/test/js/bun/test/parallel/test-http-can-send-deflate-from-Server-and-receive-with-fetch.ts index 99851ca210..b6621305ae 100644 --- a/test/js/bun/test/parallel/test-http-can-send-deflate-from-Server-and-receive-with-fetch.ts +++ b/test/js/bun/test/parallel/test-http-can-send-deflate-from-Server-and-receive-with-fetch.ts @@ -7,8 +7,8 @@ const { expect } = createTest(import.meta.path); await using server = createServer((req, res) => { expect(req.url).toBe("/hello"); - res.writeHead(200); res.setHeader("content-encoding", "deflate"); + res.writeHead(200); const inputStream = new stream.Readable(); inputStream.push("Hello World"); diff --git a/test/js/bun/test/parallel/test-http-can-send-gzip-from-Server-and-receive-with-fetch.ts b/test/js/bun/test/parallel/test-http-can-send-gzip-from-Server-and-receive-with-fetch.ts index 2058a1a01e..d05ef8d5bc 100644 --- a/test/js/bun/test/parallel/test-http-can-send-gzip-from-Server-and-receive-with-fetch.ts +++ b/test/js/bun/test/parallel/test-http-can-send-gzip-from-Server-and-receive-with-fetch.ts @@ -7,8 +7,8 @@ const { expect } = createTest(import.meta.path); await using server = createServer((req, res) => { expect(req.url).toBe("/hello"); - res.writeHead(200); res.setHeader("content-encoding", "gzip"); + res.writeHead(200); const inputStream = new stream.Readable(); inputStream.push("Hello World"); diff --git a/test/js/bun/test/parallel/test-http-client-should-use-content-length-if-only-one-write-is-called.ts b/test/js/bun/test/parallel/test-http-client-should-use-content-length-if-only-one-write-is-called.ts deleted file mode 100644 index e3afefea09..0000000000 --- a/test/js/bun/test/parallel/test-http-client-should-use-content-length-if-only-one-write-is-called.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { createTest } from "node-harness"; -import { once } from "node:events"; -import http from "node:http"; -const { expect } = createTest(import.meta.path); - -await using server = http.createServer((req, res) => { - if (req.headers["transfer-encoding"] === "chunked") { - return res.writeHead(500).end(); - } - res.writeHead(200); - req.on("data", data => { - res.write(data); - }); - req.on("end", () => { - res.end(); - }); -}); - -await once(server.listen(0, "127.0.0.1"), "listening"); - -// Options for the HTTP request -const options = { - hostname: "127.0.0.1", // Replace with the target server - port: server.address().port, - path: "/api/data", - method: "POST", - headers: { - "Content-Type": "application/json", - }, -}; - -const { promise, resolve, reject } = Promise.withResolvers(); - -// Create the request -const req = http.request(options, res => { - if (res.statusCode !== 200) { - reject(new Error("Body should not be chunked")); - } - const chunks = []; - // Collect the response data - res.on("data", chunk => { - chunks.push(chunk); - }); - - res.on("end", () => { - resolve(chunks); - }); -}); -// Handle errors -req.on("error", reject); -// Write chunks to the request body -req.write("Hello World BUN!"); -// End the request and signal no more data will be sent -req.end(); - -const chunks = await promise; -expect(chunks.length).toBe(1); -expect(chunks[0]?.toString()).toBe("Hello World BUN!"); -expect(Buffer.concat(chunks).toString()).toBe("Hello World BUN!"); diff --git a/test/js/bun/test/parallel/test-http-do-https-request-fails.ts b/test/js/bun/test/parallel/test-http-do-https-request-fails.ts index 4cbdae0385..6fc118c0c5 100644 --- a/test/js/bun/test/parallel/test-http-do-https-request-fails.ts +++ b/test/js/bun/test/parallel/test-http-do-https-request-fails.ts @@ -1,7 +1,7 @@ import { createTest, exampleSite } from "node-harness"; import http from "node:http"; const { expect } = createTest(import.meta.path); -using server = exampleSite("https"); +await using server = exampleSite("https"); expect(() => http.request(server.url)).toThrow(TypeError); expect(() => http.request(server.url)).toThrow({ code: "ERR_INVALID_PROTOCOL", diff --git a/test/js/bun/test/parallel/test-http-get-can-use-Agent.ts b/test/js/bun/test/parallel/test-http-get-can-use-Agent.ts index 06452b9380..ea5a0a5679 100644 --- a/test/js/bun/test/parallel/test-http-get-can-use-Agent.ts +++ b/test/js/bun/test/parallel/test-http-get-can-use-Agent.ts @@ -6,5 +6,5 @@ const agent = new http.Agent(); const { promise, resolve } = Promise.withResolvers(); http.get({ agent, hostname: "google.com" }, resolve); const response = await promise; -expect(response.req.port).toBe(80); +expect(response.req.agent.defaultPort).toBe(80); expect(response.req.protocol).toBe("http:"); diff --git a/test/js/bun/test/parallel/test-http-request-has-the-correct-options.ts b/test/js/bun/test/parallel/test-http-request-has-the-correct-options.ts index 7e7f5d094c..d1c4a476f4 100644 --- a/test/js/bun/test/parallel/test-http-request-has-the-correct-options.ts +++ b/test/js/bun/test/parallel/test-http-request-has-the-correct-options.ts @@ -5,5 +5,5 @@ const { expect } = createTest(import.meta.path); const { promise, resolve } = Promise.withResolvers(); http.request("http://google.com/", resolve).end(); const response = await promise; -expect(response.req.port).toBe(80); +expect(response.req.agent.defaultPort).toBe(80); expect(response.req.protocol).toBe("http:"); diff --git a/test/js/bun/test/parallel/test-https-get-can-use-Agent.ts b/test/js/bun/test/parallel/test-https-get-can-use-Agent.ts index a172192cc8..09719ac5b4 100644 --- a/test/js/bun/test/parallel/test-https-get-can-use-Agent.ts +++ b/test/js/bun/test/parallel/test-https-get-can-use-Agent.ts @@ -6,5 +6,5 @@ const agent = new https.Agent(); const { promise, resolve } = Promise.withResolvers(); https.get({ agent, hostname: "google.com" }, resolve); const response = await promise; -expect(response.req.port).toBe(443); +expect(response.req.agent.defaultPort).toBe(443); expect(response.req.protocol).toBe("https:"); diff --git a/test/js/bun/test/parallel/test-https-request-has-the-correct-options.ts b/test/js/bun/test/parallel/test-https-request-has-the-correct-options.ts deleted file mode 100644 index 54e49939a8..0000000000 --- a/test/js/bun/test/parallel/test-https-request-has-the-correct-options.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createTest } from "node-harness"; -import https from "node:https"; -const { expect } = createTest(import.meta.path); - -const { promise, resolve } = Promise.withResolvers(); -https.request("https://google.com/", resolve).end(); -const response = await promise; -expect(response.req.port).toBe(443); -expect(response.req.protocol).toBe("https:"); diff --git a/test/js/node/http/node-http-proxy.js b/test/js/node/http/node-http-proxy.js index 258c0014d9..8b82678ae9 100644 --- a/test/js/node/http/node-http-proxy.js +++ b/test/js/node/http/node-http-proxy.js @@ -4,7 +4,7 @@ import { createServer, request } from "node:http"; export async function run() { const { promise, resolve, reject } = Promise.withResolvers(); - using server = exampleSite("http"); + await using server = exampleSite("http"); const proxyServer = createServer(function (req, res) { // Use URL object instead of deprecated url.parse const parsedUrl = new URL(req.url, `http://${req.headers.host}`); diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index aaf0d24a93..fc8f4f087c 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -863,7 +863,7 @@ describe("node:http", () => { describe("https.request with custom tls options", () => { it("supports custom tls args", async () => { - using httpsServer = exampleSite(); + await using httpsServer = exampleSite(); const { promise, resolve, reject } = Promise.withResolvers(); const options: https.RequestOptions = { diff --git a/test/no-validate-exceptions.txt b/test/no-validate-exceptions.txt index 6ba7a6246a..8807f459ca 100644 --- a/test/no-validate-exceptions.txt +++ b/test/no-validate-exceptions.txt @@ -121,6 +121,8 @@ test/napi/node-napi-tests/test/node-api/test_make_callback_recurse/do.test.ts test/napi/node-napi-tests/test/node-api/test_threadsafe_function/do.test.ts test/napi/node-napi-tests/test/node-api/test_worker_terminate_finalization/do.test.ts test/napi/node-napi-tests/test/node-api/test_reference_by_node_api_version/do.test.ts +test/napi/node-napi-tests/test/node-api/test_env_teardown_gc/do.test.ts +test/napi/node-napi-tests/test/node-api/test_general/do.test.ts # normalizeCryptoAlgorithmParameters test/js/node/test/parallel/test-webcrypto-derivekey.js