mirror of
https://github.com/nodejs/node.git
synced 2025-05-12 00:24:09 +00:00

When iterating over diagnostics channel subscribers, assume their count is zero if the list of subscribers becomes undefined, because there may be only one subscriber which may unsubscribe itself as part of its onMessage handler. Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com> PR-URL: https://github.com/nodejs/node/pull/48933 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: theanarkh <theratliter@gmail.com>
15 lines
396 B
JavaScript
15 lines
396 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const dc = require('node:diagnostics_channel');
|
|
|
|
const channel_name = 'test:channel';
|
|
const published_data = 'some message';
|
|
|
|
const onMessageHandler = common.mustCall(() => dc.unsubscribe(channel_name, onMessageHandler));
|
|
|
|
dc.subscribe(channel_name, onMessageHandler);
|
|
|
|
// This must not throw.
|
|
dc.channel(channel_name).publish(published_data);
|