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: nodejs#42714
Fixes: nodejs#44143
  • Loading branch information
kvakil committed Aug 5, 2022
1 parent 9ec2787 commit 254ae86
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 254ae86

Please sign in to comment.