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

fix: support node v18 #1906

Closed
wants to merge 1 commit into from
Closed

fix: support node v18 #1906

wants to merge 1 commit into from

Conversation

ghermeto
Copy link
Member

@ghermeto ghermeto commented May 8, 2022

What?

Backward compatible change to support Node v18.

Why?

Node v18 breaking changes:

  • Added a Reader.closed getter that clashes with the Request.prototype.closed() patch.
  • Changed the data type of server.address().family from string (IPv6) to a number (6)

Drawbacks

I don't particularly like this change because it will be unexpected to people using Node18 that closed will be a method and not a getter. I would prefer to limit Restify 8.x to Node 17 and make a breaking change for 9.x by changing the method name to isClosed() or better yet, drop the method in favor of patching a getter for node v10~v17.

@restify/current-core please advise on the preferred action plan.

* fix Request.prototype.closed() clash with new Reader.closed (GH-1888)
* fix IPv6 url by supporting new server.address().family format
* add node 18 to GH Actions
@ghermeto ghermeto requested a review from a team May 8, 2022 02:26
@ghermeto
Copy link
Member Author

@DonutEspresso thoughts?

@petershaw
Copy link

Is there is a roadmap for reviewing and merging node18 support? How can I help?

@jcdalton2201
Copy link

Are there any updates on this PR? We are blocked from a security update until this is solved.

@ghermeto
Copy link
Member Author

cc/ @mmarchini @wesleytodd

Can you advise what is the preferred path to add support to Node 18?

@ben
Copy link

ben commented Sep 21, 2022

FWIW here's another ping. We'd love to be on node 18, but can't start up without this patch.

* @see https://github.com/restify/node-restify/issues/1888
*/
Object.defineProperty(Request.prototype, 'closed', {
get: function getter(x) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the x arg redundant?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this code continues to remain necessary (see my overall review comment) @ghermeto Please remove the x. @meteorlxy is correct that it is unnecessary.

Copy link

@sternam sternam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment if we stay with this approach, but at a higher level, why isn't it preferable to address the problem by refactoring restify to just use the closed getter directly instead of relying on Request having a closed property? Then this change would be unnecessary.

* @see https://github.com/restify/node-restify/issues/1888
*/
Object.defineProperty(Request.prototype, 'closed', {
get: function getter(x) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this code continues to remain necessary (see my overall review comment) @ghermeto Please remove the x. @meteorlxy is correct that it is unnecessary.

var self = this;
return self.connectionState() === 'close';
};
if (this._readableState && 'close' in this._readableState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
if (this._readableState && 'close' in this._readableState) {
if (this._readableState && 'closed' in this._readableState) {

and tests are failing with typo fixed. I'm trying to figure out if there's a way to do this without monkey patching.

@mmarchini
Copy link
Contributor

One alternative we're considering is to just remove the closed monkey patch and let restify codebase as well as users rely on connectionState instead: #1929. We might want to add a deprecation warning first though

@mmarchini
Copy link
Contributor

Closing since we're moving forward with #1929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants