MCPcopy Create free account
hub / github.com/nodejs/node / captureRejections

Function captureRejections

test/parallel/test-event-capture-rejections.js:29–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27inherits(NoConstructor, EventEmitter);
28
29function captureRejections() {
30 const ee = new EventEmitter({ captureRejections: true });
31 const _err = new Error('kaboom');
32 ee.on('something', common.mustCall(async (value) => {
33 throw _err;
34 }));
35
36 ee.on('error', common.mustCall((err) => {
37 assert.strictEqual(err, _err);
38 process.nextTick(captureRejectionsTwoHandlers);
39 }));
40
41 ee.emit('something');
42}
43
44function captureRejectionsTwoHandlers() {
45 const ee = new EventEmitter({ captureRejections: true });

Calls 2

onMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected