Compression middleware changes behavior of undefined statusText in writeHead
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript, node.js
- Domain
- backend
Research direction
Run the attached reproduction with npm install and node pure-node-compression-test.js, comparing compression middleware with and without compression and with an undefined or string status text. Trace how the middleware handles response.writeHead(200, undefined, {'foo': 'bar'}); done means the headers are set consistently when statusText is undefined.
Written by the indexing model from the issue text.
Description
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?
- 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.
- In the response handler, call response.writeHead(200, undefined, {'foo': 'bar'}). The status code and headers are not important. The important part is the
undefinedstatus 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
- Dominant language
- JavaScript
- Stars
- 2.8k
- Forks
- 254
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from expressjs/compression
-
Compression v2 Open
expressjs/compression#234 · 1 reaction · 2 assignees ·
-
awaiting more info bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
expressjs/compression#220 · 11 comments · 2 reactions ·
-
Support zstd Openenhancement future
Difficulty 4/5 3-5 days Newbie friendliness 30/100
expressjs/compression#217 · 4 comments · 11 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
expressjs/compression#185 · 9 comments · 1 reaction ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
expressjs/compression#135 · 2 comments ·
All issues in expressjs/compression
Similar issues
-
curation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
amponce/archive-movie-browser#186 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
clerk/javascript#9852 ·
-
bug p1 tools
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
factory-active factory-automatic task-bug-reproduction-cannot-reproduce task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 84/100