Skip to content

Commit

Permalink
Prepare for Node.js 15.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Sep 10, 2020
1 parent 29d4e32 commit c126ff1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ const prepareServer = (server: ExtendedTestServer, clock: GlobalClock): {emitter
const promise = new Promise((resolve, reject) => {
server.all('/abort', async (request, response) => {
emitter.emit('connection');

request.once('aborted', resolve);
response.once('finish', reject.bind(null, new Error('Request finished instead of aborting.')));

await pEvent(request, 'end');
try {
await pEvent(request, 'end');
} catch {
// Node.js 15.0.0 throws AND emits `aborted`
}

response.end();
});

Expand Down

0 comments on commit c126ff1

Please sign in to comment.