Skip to content

Commit 9f1d249

Browse files
committed
feat: support Node.js 20
1 parent cbd16ef commit 9f1d249

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- 14.x
3232
- 16.x
3333
- 18.x
34+
- 20.x
3435
runs-on: ${{matrix.os}}
3536
steps:
3637
- uses: actions/checkout@v2

test/server.test.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,9 @@ test('fire event on error', function(t) {
10941094
});
10951095
});
10961096

1097-
test('error handler defers "after" event', function(t) {
1097+
test('error handler defers "after" event', async function(t) {
1098+
let afterResolve;
1099+
let clientResolve;
10981100
t.expect(9);
10991101
SERVER.once('NotFound', function(req, res, err, cb) {
11001102
t.ok(req);
@@ -1107,7 +1109,7 @@ test('error handler defers "after" event', function(t) {
11071109
SERVER.once('after', function(req2, res2) {
11081110
t.ok(req2);
11091111
t.ok(res2);
1110-
t.end();
1112+
afterResolve();
11111113
});
11121114
return cb();
11131115
});
@@ -1118,8 +1120,18 @@ test('error handler defers "after" event', function(t) {
11181120
CLIENT.get('/' + uuid.v4(), function(err, _, res) {
11191121
t.ok(err);
11201122
t.equal(res.statusCode, 404);
1121-
t.end();
1123+
clientResolve();
11221124
});
1125+
1126+
await Promise.all([
1127+
new Promise(resolve => {
1128+
afterResolve = resolve;
1129+
}),
1130+
new Promise(resolve => {
1131+
clientResolve = resolve;
1132+
})
1133+
]);
1134+
t.end();
11231135
});
11241136

11251137
// eslint-disable-next-line
@@ -1916,7 +1928,9 @@ test("should emit 'close' on server close", function(t) {
19161928
});
19171929
});
19181930

1919-
test('should cleanup inflight requests count for 404s', function(t) {
1931+
test('should cleanup inflight requests count for 404s', async function(t) {
1932+
let afterResolve;
1933+
let clientResolve;
19201934
SERVER.get('/foo1', function(req, res, next) {
19211935
t.equal(SERVER.inflightRequests(), 1);
19221936
res.send();
@@ -1926,7 +1940,7 @@ test('should cleanup inflight requests count for 404s', function(t) {
19261940
SERVER.on('after', function(req) {
19271941
if (req.path() === '/doesnotexist') {
19281942
t.equal(SERVER.inflightRequests(), 0);
1929-
t.end();
1943+
afterResolve();
19301944
}
19311945
});
19321946

@@ -1939,8 +1953,19 @@ test('should cleanup inflight requests count for 404s', function(t) {
19391953
t.ok(err2);
19401954
t.equal(res2.statusCode, 404);
19411955
t.equal(SERVER.inflightRequests(), 0);
1956+
clientResolve();
19421957
});
19431958
});
1959+
1960+
await Promise.all([
1961+
new Promise(resolve => {
1962+
afterResolve = resolve;
1963+
}),
1964+
new Promise(resolve => {
1965+
clientResolve = resolve;
1966+
})
1967+
]);
1968+
t.end();
19441969
});
19451970

19461971
test('should cleanup inflight requests count for timeouts', function(t) {

0 commit comments

Comments
 (0)