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

Function nextError

test/parallel/test-events-on-async-iterator.js:159–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

157}
158
159async function nextError() {
160 const ee = new EventEmitter();
161 const iterable = on(ee, 'foo');
162 const _err = new Error('kaboom');
163 process.nextTick(function() {
164 ee.emit('error', _err);
165 });
166 const results = await Promise.allSettled([
167 iterable.next(),
168 iterable.next(),
169 iterable.next(),
170 ]);
171 assert.deepStrictEqual(results, [{
172 status: 'rejected',
173 reason: _err,
174 }, {
175 status: 'fulfilled',
176 value: {
177 value: undefined,
178 done: true,
179 },
180 }, {
181 status: 'fulfilled',
182 value: {
183 value: undefined,
184 done: true,
185 },
186 }]);
187 assert.strictEqual(ee.listeners('error').length, 0);
188}
189
190async function iterableThrow() {
191 const ee = new EventEmitter();

Callers

nothing calls this directly

Calls 3

nextMethod · 0.65
onFunction · 0.50
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…