Skip to content

Commit

Permalink
Resolve after server is closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Jul 18, 2023
1 parent c833faa commit bf8bb57
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/node-integration-tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export class TestEnv {
// Ex: Remix scope bleed tests.
nock.cleanAll();

this._closeServer();
void this._closeServer().then(() => {
resolve(envelopes);
});
}

resolve(envelopes);
Expand Down Expand Up @@ -300,19 +302,24 @@ export class TestEnv {

nock.cleanAll();

this._closeServer();
resolve(reqCount);
void this._closeServer().then(() => {
resolve(reqCount);
});
}, options.timeout || 1000);
});
}

private _closeServer(): void {
this.server.close(() => {
// @ts-ignore closeAllConnections() is only available from Node v18.2.0
if (NODE_VERSION >= 18 && this.server.closeAllConnections) {
// @ts-ignore (Only available in Node 18+)
this.server.closeAllConnections();
}
private _closeServer(): Promise<void> {
return new Promise<void>(resolve => {
this.server.close(() => {
// @ts-ignore closeAllConnections() is only available from Node v18.2.0
if (NODE_VERSION >= 18 && this.server.closeAllConnections) {
// @ts-ignore (Only available in Node 18+)
this.server.closeAllConnections();
}
});

resolve();
});
}
}

0 comments on commit bf8bb57

Please sign in to comment.