From 03d98113ff219894feaccd7f5aa99552d8ea6257 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Sat, 6 Aug 2022 23:57:29 -0700 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 PR-URL: https://github.com/nodejs/node/pull/44144 Reviewed-By: Stephen Belanger Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Joyee Cheung --- 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 c03078a1265..4004cbf8df7 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); }));