Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Node.js 20 #1961

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- 14.x
- 16.x
- 18.x
- 20.x
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
Expand Down
35 changes: 30 additions & 5 deletions test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,9 @@
});
});

test('error handler defers "after" event', function(t) {
test('error handler defers "after" event', async function(t) {
let afterResolve;
let clientResolve;
t.expect(9);
SERVER.once('NotFound', function(req, res, err, cb) {
t.ok(req);
Expand All @@ -1107,7 +1109,7 @@
SERVER.once('after', function(req2, res2) {
t.ok(req2);
t.ok(res2);
t.end();
afterResolve();
});
return cb();
});
Expand All @@ -1118,8 +1120,18 @@
CLIENT.get('/' + uuid.v4(), function(err, _, res) {
t.ok(err);
t.equal(res.statusCode, 404);
t.end();
clientResolve();
});

await Promise.all([
new Promise(resolve => {
afterResolve = resolve;
}),
new Promise(resolve => {
clientResolve = resolve;
})
]);
t.end();
});

// eslint-disable-next-line
Expand Down Expand Up @@ -1916,7 +1928,9 @@
});
});

test('should cleanup inflight requests count for 404s', function(t) {
test('should cleanup inflight requests count for 404s', async function(t) {
let afterResolve;
let clientResolve;
SERVER.get('/foo1', function(req, res, next) {
t.equal(SERVER.inflightRequests(), 1);
res.send();
Expand All @@ -1926,7 +1940,7 @@
SERVER.on('after', function(req) {
if (req.path() === '/doesnotexist') {
t.equal(SERVER.inflightRequests(), 0);
t.end();
afterResolve();
}
});

Expand All @@ -1939,8 +1953,19 @@
t.ok(err2);
t.equal(res2.statusCode, 404);
t.equal(SERVER.inflightRequests(), 0);
clientResolve();
});
});

await Promise.all([
new Promise(resolve => {
afterResolve = resolve;
}),
new Promise(resolve => {
clientResolve = resolve;
})
]);
t.end();
});

test('should cleanup inflight requests count for timeouts', function(t) {
Expand Down Expand Up @@ -2054,7 +2079,7 @@
});

// // check /foo
// TODO: should it contain use handlers?

Check warning on line 2082 in test/server.test.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment
t.equal(debugInfo.routes[0].handlers[0], 'use');
t.equal(debugInfo.routes[0].handlers[1], 'use2');
t.equal(debugInfo.routes[0].handlers[2], 'anonymous');
Expand Down
Loading