node/test/parallel/test-diagnostics-channel-safe-subscriber-errors.js
Stephen Belanger c6c36c3da7 lib: create diagnostics_channel module
PR-URL: https://github.com/nodejs/node/pull/34895
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2020-10-31 21:24:11 +00:00

30 lines
630 B
JavaScript

'use strict';
const common = require('../common');
const dc = require('diagnostics_channel');
const assert = require('assert');
const input = {
foo: 'bar'
};
const channel = dc.channel('fail');
const error = new Error('nope');
process.on('uncaughtException', common.mustCall((err) => {
assert.strictEqual(err, error);
}));
channel.subscribe(common.mustCall((message, name) => {
throw error;
}));
// The failing subscriber should not stop subsequent subscribers from running
channel.subscribe(common.mustCall());
// Publish should continue without throwing
const fn = common.mustCall();
channel.publish(input);
fn();