Skip to content

Commit

Permalink
chore: cleanup global reject handler leaking into tests (electron#40689)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 authored and MrHuangJser committed Dec 11, 2023
1 parent e998faf commit dc1e731
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions spec/node-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,22 +867,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'));
});
};

let called = false;
process.once('unhandledRejection', () => {
if (called) return;

done(new Error('catch block is delayed to next tick'));
called = true;
});

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

0 comments on commit dc1e731

Please sign in to comment.