Skip to content

Commit

Permalink
feat!: support v18.x
Browse files Browse the repository at this point in the history
* Remove `closed()` monkey-patch, rely on connectionState instead (GH-1888)
* fix IPv6 url by supporting new server.address().family format
* add node 18 to GH Actions

Co-authored-by: mary marchini <oss@mmarchini.me>
  • Loading branch information
ghermeto and mmarchini committed Nov 29, 2022
1 parent f384900 commit 5795223
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 45 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Expand Up @@ -30,6 +30,7 @@ jobs:
node-version:
- 14.x
- 16.x
- 18.x
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
Expand Down
20 changes: 0 additions & 20 deletions lib/request.js
Expand Up @@ -2,7 +2,6 @@

'use strict';

const { emitWarning } = require('node:process');
var url = require('url');
var sprintf = require('util').format;

Expand Down Expand Up @@ -837,25 +836,6 @@ function patch(Request) {
return self._connectionState;
};

/**
* Returns true when connection state is "close"
*
* @private
* @memberof Request
* @instance
* @function closed
* @returns {Boolean} is closed
*/
Request.prototype.closed = function closed() {
emitWarning(
'restify req.closed is deprecated, will be removed on Restify 10',
'RestifyDeprecationWarning',
'RestifyDEPReqClosed'
);
var self = this;
return self.connectionState() === 'close';
};

/**
* Returns the route object to which the current request was matched to.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Expand Up @@ -257,7 +257,7 @@ function Server(options) {

if (addr) {
str +=
addr.family === 'IPv6'
addr.family === 'IPv6' || addr.family === 6
? '[' + addr.address + ']'
: addr.address;
str += ':';
Expand Down
24 changes: 0 additions & 24 deletions test/request.test.js
Expand Up @@ -275,27 +275,3 @@ test('should emit restifyDone event when request is fully served with error', fu
clientDone = true;
});
});

test('should emit warning if closed is called', function(t) {
let warningCalled = false;
SERVER.get('/ping/:name', function(req, res, next) {
function testWarning(warning) {
t.equal(warning.name, 'RestifyDeprecationWarning');
t.equal(warning.code, 'RestifyDEPReqClosed');
t.ok(warning.stack);
warningCalled = true;

res.send('ok');
return next();
}
process.once('warning', testWarning);
t.notOk(req.closed());
});

CLIENT.get('/ping/lagavulin', function(err, _, res) {
t.ifError(err);
t.equal(res.statusCode, 200);
t.ok(warningCalled);
t.end();
});
});

0 comments on commit 5795223

Please sign in to comment.