Skip to content

Commit

Permalink
chore: cleanup global reject handler leaking into tests (#40689)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3a510a2)
  • Loading branch information
deepak1556 authored and jkleinsc committed Jan 22, 2024
1 parent 89aec5b commit 8ab4adb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions spec/node-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,16 +928,23 @@ describe('node feature', () => {
});

it('performs microtask checkpoint correctly', (done) => {
let timer : NodeJS.Timeout;
const listener = () => {
done(new Error('catch block is delayed to next tick'));
};

const f3 = async () => {
return new Promise((resolve, reject) => {
timer = setTimeout(listener);
reject(new Error('oops'));
});
};

process.once('unhandledRejection', () => done('catch block is delayed to next tick'));

setTimeout(() => {
f3().catch(() => done());
f3().catch(() => {
clearTimeout(timer);
done();
});
});
});
});

0 comments on commit 8ab4adb

Please sign in to comment.