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

v19.1.0: breaking change, http.IncomingMessage headers setter no-op #45510

Closed
dnalborczyk opened this issue Nov 18, 2022 · 5 comments · Fixed by #45527
Closed

v19.1.0: breaking change, http.IncomingMessage headers setter no-op #45510

dnalborczyk opened this issue Nov 18, 2022 · 5 comments · Fixed by #45527
Labels
http Issues or PRs related to the http subsystem.

Comments

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Nov 18, 2022

Version

19.1.0

Platform

Darwin unifi 20.6.0 Darwin Kernel Version 20.6.0: Thu Sep 29 20:15:11 PDT 2022; root:xnu-7195.141.42~1/RELEASE_X86_64 x86_64

Subsystem

V8 or http

What steps will reproduce the bug?

an OSS project of mine does some integration testing with other libraries and tests involving 2 libraries (independently used) started failing when running with v19.1.0. after digging into the code, I came up with a reduced test case.

I haven't found time to bisect yet, I can't really tell what exactly causes the issue, although I'm suspecting V8 is the culprit. I'm also not sure what the intended behavior should be, e.g. assuming V8 is the cause of the issue, if it corrected some spec related behavior, or if it broke something.

const { IncomingMessage } = require("http")

class ServerlessRequest extends IncomingMessage {
  constructor() {
    super()

    Object.assign(this, {
      headers: {
        foo: "bar",
      },
    })
  }
}

const serverlessRequest = new ServerlessRequest()

console.log(Object.hasOwn(serverlessRequest, "headers"))
console.log("headers" in serverlessRequest)
console.log(serverlessRequest.headers)
console.log(serverlessRequest.headers?.foo)

node.js 19.0.1:
false
true
{ foo: 'bar' }
bar

node.js 19.1.0
false
true
{}
undefined

How often does it reproduce? Is there a required condition?

always

What is the expected behavior?

see above

What do you see instead?

see above

Additional information

I haven't found enough time yet to look for a smaller repro without involving IncomingMessage from the http module, with something like this mirroring the http implementation, but to no avail.

function IncomingMessage() {}

Object.defineProperty(IncomingMessage.prototype, "headers", {
  __proto__: null,

  get: function () {
    return {};
  },

  set: function (value) {},
});
@anonrig
Copy link
Member

anonrig commented Nov 18, 2022

IncomingMessage headers setter became a no-op in the latest release. Referencing 4d723c7

I couldn't find a documentation change for this breaking change.

CC'ing reviewers for better understanding of this change: @mcollina @ShogunPanda @Trott

@anonrig anonrig added the http Issues or PRs related to the http subsystem. label Nov 18, 2022
@dnalborczyk
Copy link
Contributor Author

dnalborczyk commented Nov 19, 2022

thank you @anonrig , good find. after following up on the PR discussion it appears to be a breaking change which would require a semver major and should likely be rolled back, although I agree with the change. that said, I think it would have been more consequent to remove the setter altogether.

@dnalborczyk dnalborczyk changed the title v19.1.0: Object.assign behavior change v19.1.0: breaking change, http.IncomingMessage headers no-op Nov 19, 2022
@dnalborczyk dnalborczyk changed the title v19.1.0: breaking change, http.IncomingMessage headers no-op v19.1.0: breaking change, http.IncomingMessage headers setter no-op Nov 19, 2022
@Trott
Copy link
Member

Trott commented Nov 19, 2022

@nodejs/http @sonimadhuri Any thoughts on the right thing to do here? I'm not sure which of these options (or maybe some other option) is the way to go:

  1. Revert the change, reintroduce it as a breaking change, and get the word out to relevant maintainers before the next major release.
  2. Revert the change, add minimal test coverage for the setter, document a legitimate use case or two in the docs.

Trott added a commit to Trott/io.js that referenced this issue Nov 19, 2022
This reverts commit 4d723c7.

I'm not sure if we should re-apply this as a semver-major change or if
we should accept it as valid and add tests/documentation, but either
way, we have to revert it at least temporarily.

Closes: nodejs#45510
@Trott
Copy link
Member

Trott commented Nov 19, 2022

Revert is in #45527.

I think the thing to do is re-apply this as a breaking change and put it in 20.x (and warn the nock maintainers and anyone else we think might be affected). But I'll likely defer to others on this.

@sonimadhuri
Copy link
Contributor

@Trott I think all of us agree that the change is valid, so I think re-introducing this as semver major and updating documentation would be the right thing to do.

nodejs-github-bot pushed a commit that referenced this issue Nov 21, 2022
This reverts commit 4d723c7.

I'm not sure if we should re-apply this as a semver-major change or if
we should accept it as valid and add tests/documentation, but either
way, we have to revert it at least temporarily.

Closes: #45510
PR-URL: #45527
Fixes: #45510
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
luismiramirez added a commit to appsignal/appsignal-nodejs that referenced this issue Nov 23, 2022
The header setters are now no-op functions since Node.js 19.1. Nock, the
http mocking library we use for our transmitter tests uses these
setters so our tests break. This commit uses the `rawHeaders` attribute
instead to get green tests until the issue is fixed in either side.

More info: nodejs/node#45510
marco-ippolito pushed a commit to marco-ippolito/node that referenced this issue Nov 23, 2022
This reverts commit 4d723c7.

I'm not sure if we should re-apply this as a semver-major change or if
we should accept it as valid and add tests/documentation, but either
way, we have to revert it at least temporarily.

Closes: nodejs#45510
PR-URL: nodejs#45527
Fixes: nodejs#45510
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
ruyadorno pushed a commit that referenced this issue Nov 24, 2022
This reverts commit 4d723c7.

I'm not sure if we should re-apply this as a semver-major change or if
we should accept it as valid and add tests/documentation, but either
way, we have to revert it at least temporarily.

Closes: #45510
PR-URL: #45527
Fixes: #45510
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants