mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 08:42:45 +00:00

This test uses the deprecated methods in `diagnostic_channel` (see the reference), which are deprecated because the channels can be GC'd while in use, leading to lost messages. Change to use the non-deprecated APIs, which should work. I wasn't able to reproduce this locally; I assume it's memory dependent. Refs: https://github.com/nodejs/node/pull/42714 Fixes: https://github.com/nodejs/node/issues/44143 PR-URL: https://github.com/nodejs/node/pull/44144 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
26 lines
656 B
JavaScript
26 lines
656 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
const dc = require('diagnostics_channel');
|
|
|
|
const isNetSocket = (socket) => socket instanceof net.Socket;
|
|
|
|
dc.subscribe('net.client.socket', common.mustCall(({ socket }) => {
|
|
assert.strictEqual(isNetSocket(socket), true);
|
|
}));
|
|
|
|
dc.subscribe('net.server.socket', common.mustCall(({ socket }) => {
|
|
assert.strictEqual(isNetSocket(socket), true);
|
|
}));
|
|
|
|
const server = net.createServer(common.mustCall((socket) => {
|
|
socket.destroy();
|
|
server.close();
|
|
}));
|
|
|
|
server.listen(() => {
|
|
const { port } = server.address();
|
|
net.connect(port);
|
|
});
|