diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2ae6f518..81132ad60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: - 12.x - 14.x - 16.x + - 18.x runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v2 diff --git a/lib/request.js b/lib/request.js index eddd05919..f21d72641 100644 --- a/lib/request.js +++ b/lib/request.js @@ -836,6 +836,16 @@ function patch(Request) { return self._connectionState; }; + /** + * Node v18 introduced a `closed` getter to Readable stream which breaks the API + * @see https://github.com/restify/node-restify/issues/1888 + */ + Object.defineProperty(Request.prototype, 'closed', { + get: function getter(x) { + return closed; + } + }); + /** * Returns true when connection state is "close" * @@ -845,10 +855,14 @@ function patch(Request) { * @function closed * @returns {Boolean} is closed */ - Request.prototype.closed = function closed() { + function closed() { var self = this; - return self.connectionState() === 'close'; - }; + if (this._readableState && 'close' in this._readableState) { + return this._readableState.closed; + } else { + return self.connectionState() === 'close'; + } + } /** * Returns the route object to which the current request was matched to. diff --git a/lib/server.js b/lib/server.js index 3276e030a..0707aa737 100644 --- a/lib/server.js +++ b/lib/server.js @@ -257,7 +257,7 @@ function Server(options) { if (addr) { str += - addr.family === 'IPv6' + addr.family === 'IPv6' || addr.family === 6 ? '[' + addr.address + ']' : addr.address; str += ':'; diff --git a/package.json b/package.json index b0a1bb7dd..f35a35cac 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "qs": "^6.7.0", "restify-errors": "^8.0.2", "semver": "^6.1.1", - "send": "^0.17.1", + "send": "^0.18.0", "spdy": "^4.0.0", "uuid": "^3.3.2", "vasync": "^2.2.0"