MCPcopy Index your code
hub / github.com/nodejs/node / catchesErrors

Function catchesErrors

test/parallel/test-events-once.js:42–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42async function catchesErrors() {
43 const ee = new EventEmitter();
44
45 const expected = new Error('kaboom');
46 let err;
47 process.nextTick(() => {
48 ee.emit('error', expected);
49 });
50
51 try {
52 await once(ee, 'myevent');
53 } catch (_e) {
54 err = _e;
55 }
56 assert.strictEqual(err, expected);
57 assert.strictEqual(ee.listenerCount('error'), 0);
58 assert.strictEqual(ee.listenerCount('myevent'), 0);
59}
60
61async function catchesErrorsWithAbortSignal() {
62 const ee = new EventEmitter();

Callers 1

Calls 3

listenerCountMethod · 0.80
onceFunction · 0.70
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…