Compare commits

..

1 Commits

Author SHA1 Message Date
Meghan Denny
6e7becd9b9 node: fix test-net-server-close.js 2025-03-04 19:31:24 -08:00
11 changed files with 20 additions and 118 deletions

View File

@@ -471,7 +471,7 @@ function getBuildZigStep(platform, options) {
cancel_on_build_failing: isMergeQueue(),
env: getBuildEnv(platform, options),
command: `bun run build:ci --target bun-zig --toolchain ${toolchain}`,
timeout_in_minutes: 35,
timeout_in_minutes: 25,
};
}

View File

@@ -28,9 +28,4 @@ describe("example", () => {
};
}).toThrow();
});
test("can run with special chars :)", () => {
// if this test runs, it's a success.
// a failure is if it's either skipped or fails the runner
})
});

View File

@@ -171,12 +171,11 @@ export function registerTestRunner(context: vscode.ExtensionContext) {
}
if (testName && testName.length) {
const escapedTestName = escapeRegex(testName);
if (customScriptSetting.length) {
// escape the quotes in the test name
command += ` -t "${escapedTestName}"`;
command += ` -t "${testName}"`;
} else {
command += ` -t "${escapedTestName}"`;
command += ` -t "${testName}"`;
}
}
@@ -203,14 +202,3 @@ export function registerTestRunner(context: vscode.ExtensionContext) {
context.subscriptions.push(runTestCommand);
context.subscriptions.push(watchTestCommand);
}
/**
* Escape any special characters in the input string, so that regex-matching on it
* will work as expected.
* i.e `new RegExp(escapeRegex("hi (:").test("hi (:")` will return true, instead of throwing
* an invalid regex error.
*/
function escapeRegex(source: string) {
return source.replaceAll(/[^a-zA-Z0-9_+\-'"\ ]/g, "\\$&");
}

View File

@@ -1554,14 +1554,6 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_BUFFER_OUT_OF_BOUNDS, "Attempt to access memory outside buffer bounds"_s));
}
case Bun::ErrorCode::ERR_HTTP2_UNSUPPORTED_PROTOCOL: {
auto arg0 = callFrame->argument(1);
auto str0 = arg0.toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, {});
auto message = makeString("protocol \""_s, str0, "\" is unsupported."_s);
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_HTTP2_UNSUPPORTED_PROTOCOL, message));
}
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:

View File

@@ -88,7 +88,6 @@ const errors: ErrorCodeMapping = [
["ERR_INVALID_CHAR", TypeError],
["MODULE_NOT_FOUND", Error],
["ERR_SERVER_ALREADY_LISTEN", Error],
["ERR_HTTP2_UNSUPPORTED_PROTOCOL", Error],
// Bun-specific
["ERR_FORMDATA_PARSE_ERROR", TypeError],

View File

@@ -892,29 +892,7 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(void* console_client,
vm.heap.acquireAccess();
JSC::JSLockHolder locker(vm);
{
const char* disable_stop_if_necessary_timer = getenv("BUN_DISABLE_STOP_IF_NECESSARY_TIMER");
// Keep stopIfNecessaryTimer enabled by default when either:
// - `--smol` is passed
// - The machine has less than 4GB of RAM
bool shouldDisableStopIfNecessaryTimer = !miniMode;
if (WTF::ramSize() < 1024ull * 1024ull * 1024ull * 4ull) {
shouldDisableStopIfNecessaryTimer = false;
}
if (disable_stop_if_necessary_timer) {
const char value = disable_stop_if_necessary_timer[0];
if (value == '0') {
shouldDisableStopIfNecessaryTimer = false;
} else if (value == '1') {
shouldDisableStopIfNecessaryTimer = true;
}
}
if (shouldDisableStopIfNecessaryTimer) {
vm.heap.disableStopIfNecessaryTimer();
}
}
vm.heap.disableStopIfNecessaryTimer();
// Every JS VM's RunLoop should use Bun's RunLoop implementation
ASSERT(vmPtr->runLoop().kind() == WTF::RunLoop::Kind::Bun);

View File

@@ -606,7 +606,6 @@ declare function $ERR_METHOD_NOT_IMPLEMENTED(method: string): Error;
declare function $ERR_STREAM_ALREADY_FINISHED(method: string): Error;
declare function $ERR_MISSING_ARGS(a1: string, a2?: string): TypeError;
declare function $ERR_INVALID_RETURN_VALUE(expected_type: string, name: string, actual_value: any): TypeError;
declare function $ERR_HTTP2_UNSUPPORTED_PROTOCOL(protocol: string): Error;
declare function $ERR_IPC_DISCONNECTED(): Error;
declare function $ERR_SERVER_NOT_RUNNING(): Error;

View File

@@ -2155,10 +2155,7 @@ function connectWithProtocol(protocol: string, options: Http2ConnectOptions | st
if (protocol === "http:") {
return net.connect(options, listener);
}
if (protocol === "https:") {
return tls.connect(options, listener);
}
throw $ERR_HTTP2_UNSUPPORTED_PROTOCOL(protocol);
return tls.connect(options, listener);
}
function emitConnectNT(self, socket) {

View File

@@ -1,30 +0,0 @@
'use strict';
const common = require('../common');
if (!common.hasIPv6)
common.skip('no IPv6 support');
// This test ensures that dual-stack support is disabled when
// we specify the `ipv6Only` option in `net.Server.listen()`.
const assert = require('assert');
const net = require('net');
const host = '::';
const server = net.createServer();
server.listen({
host,
port: 0,
ipv6Only: true,
}, common.mustCall(() => {
const { port } = server.address();
const socket = net.connect({
host: '0.0.0.0',
port,
});
socket.on('connect', common.mustNotCall());
socket.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'ECONNREFUSED');
server.close();
}));
}));

View File

@@ -20,26 +20,26 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
// This test binds to one port, then attempts to start a server on that
// port. It should be EADDRINUSE but be able to then bind to another port.
const common = require('../common');
const assert = require('assert');
const net = require('net');
const server1 = net.Server();
const sockets = [];
const server2 = net.Server();
const server = net.createServer(function(c) {
c.on('close', common.mustCall());
server2.on('error', common.mustCall(function(e) {
assert.strictEqual(e.code, 'EADDRINUSE');
sockets.push(c);
server2.listen(0, common.mustCall(function() {
server1.close();
server2.close();
}));
}));
server1.listen(0, common.mustCall(function() {
// This should make server2 emit EADDRINUSE
server2.listen(this.address().port);
if (sockets.length === 2) {
assert.strictEqual(server.close(), server);
sockets.forEach((c) => c.destroy());
}
});
server.on('close', common.mustCall());
assert.strictEqual(server, server.listen(0, () => {
net.createConnection(server.address().port);
net.createConnection(server.address().port);
}));

View File

@@ -1,16 +0,0 @@
'use strict';
require('../common');
const assert = require('assert');
const net = require('net');
assert.throws(() => net.createServer('path'),
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
});
assert.throws(() => net.createServer(0),
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
});