Compare commits

...

3 Commits

Author SHA1 Message Date
Jarred Sumner
bff1a1c939 Merge branch 'main' into nektro-patch-5839 2025-06-26 23:38:05 -07:00
Meghan Denny
26e02588a7 Update no-validate-exceptions.txt 2025-06-24 23:12:13 -07:00
Meghan Denny
7c83962852 node: fix test-net-pipe-connect-errors.js 2025-06-24 22:36:05 -07:00
2 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
// Flags: --expose-gc
const common = require('../common');
if (require("./../../../../harness").isASAN) return;
const { onGC } = require('../common/gc');
const assert = require('assert');
const net = require('net');
// Test that the implicit listener for an 'connect' event on net.Sockets is
// added using `once()`, i.e. can be gc'ed once that event has occurred.
const server = net.createServer(common.mustCall()).listen(0);
let collected = false;
const gcListener = { ongc() { collected = true; } };
{
const gcObject = {};
onGC(gcObject, gcListener);
const sock = net.createConnection(
server.address().port,
common.mustCall(() => {
assert.strictEqual(gcObject, gcObject); // Keep reference alive
assert.strictEqual(collected, false);
setImmediate(done, sock);
}));
}
function done(sock) {
globalThis.gc(true);
setImmediate(() => {
assert.strictEqual(collected, true);
sock.end();
server.close();
});
}

View File

@@ -1262,6 +1262,7 @@ test/js/node/test/parallel/test-net-connect-destroy.js
test/js/node/test/parallel/test-net-connect-immediate-destroy.js
test/js/node/test/parallel/test-net-connect-immediate-finish.js
test/js/node/test/parallel/test-net-connect-keepalive.js
test/js/node/test/parallel/test-net-connect-memleak.js
test/js/node/test/parallel/test-net-connect-no-arg.js
test/js/node/test/parallel/test-net-connect-nodelay.js
test/js/node/test/parallel/test-net-connect-options-invalid.js