node-restify
node-restify copied to clipboard
restify cannot be imported with latest node v18.0.0 nightly: `Request.prototype.closed` patch clashes with new Readable.closed getter
- [x] Used appropriate template for the issue type
- [x] Searched both open and closed issues for duplicates of this issue
- [x] Title adequately and concisely reflects the feature or the bug
Restify Version: 8.6.0 Node.js Version: v18.0.0-nightly2021111694fa781580 (from https://nodejs.org/download/nightly/v18.0.0-nightly2021111694fa781580/)
Expected behaviour
require('restify')
does not throw
Actual behaviour
% node
Welcome to Node.js v18.0.0-nightly2021111694fa781580.
Type ".help" for more information.
> require('restify')
Uncaught TypeError: Cannot set property closed of #<Readable> which has only a getter
at patch (.../node_modules/restify/lib/request.js:848:30)
at Object.<anonymous> (.../node_modules/restify/lib/server.js:33:1)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
>
Repro case
require('restify')
Cause
Node's master branch recently added a closed
property to streams.Readable.prototype
which only has a getter:
https://github.com/nodejs/node/pull/40696/files#diff-040c1f5a53844e600d40b33c4624f1fe39fcf2f8d62c76ca3fc5ea5442231469
This is incompatible with Restify's patching of http.IncomingMessage
(which is a Readable) to add its own closed
property: https://github.com/restify/node-restify/blob/71c7f4965342c13cac55847f87149cc34c1ad566/lib/request.js#L839-L851
Are you willing and able to fix this?
Probably not. I do not use restify currently. I came across this in testing we do on our APM agent's instrumentation of restify. We periodically test against the latest node nightly build.
Bump. Node 18 is now (April 22) current.
The same issue is in the current Node v18. Restify does not work under the latest official release. This is a critical issue.
Hey 👋 I am currently using [email protected]
and I have also encountered this issue when migrating to node 18. I see there have been PRs done to try and resolve the issue. Just curious what the status is with this?
I have the same issue.
Request.prototype.closed = function closed() {
TypeError: Cannot set property closed of #<Readable> which has only a getter
So my app is crashing when using node 18.7.0 and restify v8.6.1.
I've got the same issue in node v18.0.0
any update?
Node 19 is now out, which means that Node 18 is now the current LTS.
require('restify') no longer throws this TypeError with the node 18.12.1 nor the recently released node 18.13.0. I tested this with [email protected] - which is the current version. (Note that I verified that error exists with [email protected] and node 18.13.0.)
Fixed in https://github.com/restify/node-restify/pull/1929 and (as @luisdelarosa said) in restify v10 and later.