Skip to content

Commit

Permalink
test: deflake test-diagnostics-channel-net
Browse files Browse the repository at this point in the history
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: #42714
Fixes: #44143
PR-URL: #44144
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
kvakil authored and targos committed Sep 5, 2022
1 parent 7ca6c9e commit ca1c857
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/parallel/test-diagnostics-channel-net.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ const assert = require('assert');
const net = require('net');
const dc = require('diagnostics_channel');

const netClientSocketChannel = dc.channel('net.client.socket');
const netServerSocketChannel = dc.channel('net.server.socket');

const isNetSocket = (socket) => socket instanceof net.Socket;

netClientSocketChannel.subscribe(common.mustCall(({ socket }) => {
dc.subscribe('net.client.socket', common.mustCall(({ socket }) => {
assert.strictEqual(isNetSocket(socket), true);
}));

netServerSocketChannel.subscribe(common.mustCall(({ socket }) => {
dc.subscribe('net.server.socket', common.mustCall(({ socket }) => {
assert.strictEqual(isNetSocket(socket), true);
}));

Expand Down

0 comments on commit ca1c857

Please sign in to comment.