Skip to content

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

Closed
@dnalborczyk

Description

@dnalborczyk

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) {},
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions