From 254ae86b2c45c1b5e40b68167e1c0991b13329ea Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Fri, 5 Aug 2022 09:34:52 +0000 Subject: [PATCH] test: deflake test-diagnostics-channel-net 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 --- test/parallel/test-diagnostics-channel-net.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-diagnostics-channel-net.js b/test/parallel/test-diagnostics-channel-net.js index c03078a12659ac..4004cbf8df7a00 100644 --- a/test/parallel/test-diagnostics-channel-net.js +++ b/test/parallel/test-diagnostics-channel-net.js @@ -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); }));