Skip to content

Compression middleware changes behavior of undefined statusText in writeHead #254

@Siretu

Description

@Siretu

Environment information

Version: Compression 1.8.1

Platform: MacOS 15.6

Node.js version: 22.15.1

Any other relevant information:

What steps will reproduce the bug?

  1. Setup a node server with the compression middleware. You can also set the filter method to always return false, to ensure it's not doing any compression.
  2. In the response handler, call response.writeHead(200, undefined, {'foo': 'bar'}). The status code and headers are not important. The important part is the undefined status text

Observe how the response headers are not getting set at all.
If you change the status text from undefined to any string, the headers do get set.
If you leave the undefined status text, but remove the compression middleware, the headers do get set.

I've attached a repro case showing this. Just npm install and then run the test with node pure-node-compression-test.js

compression-repro.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions