GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bugfix/use write head instead of implicit header by Icehunter · Pull Request #170 · expressjs/compression

Conversation

@Icehunter

@Icehunter Icehunter commented Mar 2, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

updated PR with rebase from express/compress:master to handle #128

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

EvHaus and lamweili reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@dougwilson

dougwilson commented Mar 2, 2020

Copy link
Copy Markdown
Contributor

Just wanted to note on here it looks like just a rebase, without addressing the review comments yet. I presume that will come in follow up commits?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Icehunter

Icehunter commented Mar 2, 2020

Copy link
Copy Markdown
Contributor Author

Just wanted to note on here it looks like just a rebase, without addressing the review comments yet. I presume that will come in follow up commits?

Yes, working on that now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Icehunter

Icehunter commented Mar 2, 2020

Copy link
Copy Markdown
Contributor Author

@dougwilson I found all the comments I think needed to be fixed, except 2 perhaps that I'll work on tonight.

  1. the on('data') callback which I think doesn't need a data check; per the noop it's just a way to prevent hangs
  2. the comments from @sogaani regarding the response code. I'll look at that as well.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Icehunter

Icehunter commented Apr 13, 2020

Copy link
Copy Markdown
Contributor Author

@dougwilson Is there anything more you see for this PR to have?
@sogaani with regards to your comment on the error status code; it seems to be a big edge case. I work on a very large API and haven't encountered this issue before.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dougwilson

dougwilson commented Apr 13, 2020

Copy link
Copy Markdown
Contributor

I was under the impression you were going to make changes in regards to the two bullet points above, which is what I'm waiting on. I never saw any additional comments after that message. Are you still working on them?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Icehunter

Icehunter commented Apr 16, 2020

Copy link
Copy Markdown
Contributor Author

Eh! Sorry; I did leave the on('data') callback as is in the test, but I removed all the logs and I believe covered everything you had commented on in the previous test.

For the second bullet point I quite literally have no clue off the top of my head how to even cover that in an edge case test.

lukasoppermann and lamweili reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dougwilson dougwilson added the pr label Jul 10, 2020
@valoricDe

valoricDe commented May 5, 2021

Copy link
Copy Markdown

Seems like this one got stuck right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lamweili
lamweili suggested changes Jul 30, 2022
View reviewed changes

@lamweili lamweili left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Hi @Icehunter and @dougwilson,

IMHO, there are two issues covered by this PR.

  1. Switching from an undocumented API to a public API.
    This is definitely preferred. Current tests should suffice as there are no logical changes.
  2. Supporting http2 as a by-product.
    Additional tests required to prove support on http2.

I addressed the on('data') callback as mentioned in #128 (comment) and #170 (comment) with the following suggestions.
It now asserts that the data is correct.

Go to the Files tab and Add suggestion to batch so that it becomes a singular commit.
You might also want to correct the indentations within the function closeHttp2 at line 733.

I believe with this, all outstanding review comments in #128 are addressed and this PR should be ready and supersede #128.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@lamweili

lamweili commented Jul 30, 2022

Copy link
Copy Markdown
Contributor

@Icehunter, you might want to correct the indentations at line 740-744 and line 747-753.
I didn't include them previously so that 38fe9fd is surgical.

compression/test/compression.js

Lines 737 to 756 in 38fe9fd

function closeHttp2 (client, server, callback) {
if (typeof client.shutdown === 'function') {
// this is the node v8.x way of closing the connections
client.shutdown({}, function () {
server.close(function () {
callback()
})
})
} else {
// this is the node v9.x onwards way of closing the connections
client.close(function () {
// force existing connections to time out after 1ms.
// this is done to force the server to close in some cases where it wouldn't do it otherwise.
server.close(function () {
callback()
})
})
}
}

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lamweili

lamweili commented Jul 30, 2022

Copy link
Copy Markdown
Contributor

@Icehunter, for the clarity that #129 is not in this PR, the description should change:

updated PR with rebase from express/compress:master to handle #128 and #129

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Moritz Peters and others added 13 commits July 30, 2022 12:33
Moritz Peters @Icehunter
Add failing tests for http2
f160f44
Moritz Peters @Icehunter
Add support for http2
2c8ed82
The change just removes the usage of undocumented http API and instead uses the proper writeHead method
Moritz Peters @Icehunter
Remove arrow function in tests
8eae006
Moritz Peters @Icehunter
Conditionally run http2 tests if http2 is available
8c68bc1
Moritz Peters @Icehunter
Fix port in tests to be assigned automatically
5122916
Moritz Peters @Icehunter
Change http2 test usage to describe.skip if no http2 available
7b7f506
Moritz Peters @Icehunter
Fix closing the http2 connections to prevent possible exceptions
8ba8100
Moritz Peters @Icehunter
Fix closing the request first, then the client, then the server
8ea806d
Moritz Peters @Icehunter
Fix closing for v8.x and v9.x
a562056
@maritz @Icehunter
fix tests not draining data for http2 requests, resulting in timeouts…
feddec1
… in node v10.4 onwards
@Icehunter
fix: 🐛 assert.equal error
5124eb0
@Icehunter
fix: 🐛 remove console.log's and timeout, let build fail
094316e
@Icehunter @lamweili
Apply suggestions from code review
d85e6e8
Co-authored-by: Lam Wei Li <[email protected]>
@Icehunter
Icehunter force-pushed the bugfix/use_writeHead_instead_of_implicitHeader branch from 38fe9fd to d85e6e8 Compare July 30, 2022 19:33
@Icehunter

Icehunter commented Jul 30, 2022

Copy link
Copy Markdown
Contributor Author

@Icehunter, for the clarity that #129 is not in this PR, the description should change:

updated PR with rebase from express/compress:master to handle #128 and #129

Updated and rebased again :)

lamweili reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lamweili
lamweili force-pushed the bugfix/use_writeHead_instead_of_implicitHeader branch from 0dafcad to b908af0 Compare August 2, 2022 07:36
This was referenced Aug 2, 2022
Fix usage of undocumented _implicitHeader #128
Closed
refactor: replaced _implicitHeader expressjs/session#908
Closed
@lamweili
lamweili force-pushed the bugfix/use_writeHead_instead_of_implicitHeader branch from 4d77342 to b908af0 Compare August 2, 2022 08:37
@lamweili
lamweili force-pushed the bugfix/use_writeHead_instead_of_implicitHeader branch from b908af0 to 4c1d27b Compare August 2, 2022 09:49
@lamweili

lamweili commented Aug 4, 2022

Copy link
Copy Markdown
Contributor

@dougwilson When you are free, can you review this PR?
Fixes #122 and supersedes #128.
Many thanks! 🤗

I didn't have access in the forked repository to run the GH actions. So I forked the PR.
I ran the GH actions on my own repository and here is the result for the latest commit (4c1d27b):
https://github.com/lamweili/compression/actions

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lamweili

lamweili commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

@dougwilson, have you got the time to take a look at this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jordanst3wart jordanst3wart mentioned this pull request Sep 25, 2023
code samples, an interface, or middleware for fastify (express is becoming legacy) auth0/express-openid-connect#504
Closed
5 tasks done
@bjohansebas bjohansebas mentioned this pull request Sep 20, 2024
Release 1.8.0 #189
Closed
@bjohansebas bjohansebas added this to the 1.8.0 milestone Nov 3, 2024
bjohansebas
bjohansebas reviewed Nov 3, 2024
View reviewed changes
Comment thread test/compression.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas requested review from a team and UlisesGascon November 4, 2024 00:16
bjohansebas
bjohansebas approved these changes Nov 4, 2024
View reviewed changes
@bjohansebas bjohansebas self-assigned this Nov 4, 2024
@bjohansebas bjohansebas added enhancement and removed pr labels Nov 4, 2024
@Icehunter
Icehunter requested a review from lamweili November 4, 2024 00:31
lamweili
lamweili reviewed Nov 4, 2024
View reviewed changes

@lamweili lamweili left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

(can't approve cause I don't have explicit access to this repository)
😮‍💨

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas
Merge branch 'master' into bugfix/use_writeHead_instead_of_implicitHe…
ec797a7
…ader
@bjohansebas

bjohansebas commented Nov 9, 2024

Copy link
Copy Markdown
Member

sorry @Icehunter, Can you fix the code style?

Icehunter reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Icehunter

Icehunter commented Nov 9, 2024

Copy link
Copy Markdown
Contributor Author

sorry @Icehunter, Can you fix the code style?

Sure thing.

bjohansebas reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Icehunter
fix lint issue
c126f78
@Icehunter
Icehunter requested a review from lamweili November 9, 2024 18:10
@jonchurch jonchurch mentioned this pull request Nov 10, 2024
Support for Node.js 8 native http2 #122
Open
@jonchurch

jonchurch commented Nov 10, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Dropping some context from slack re: this PR

The original issue here is compression relying on node http internals since the days of connect in 2011

Here's when the commit w/ _implicitHeader originally landed:

senchalabs/connect@715e4f5

http2 module has a different API and internals than http1 in node. So that method doesn't exist at all in http2, throwing when used.

Compression module doesn't support http2 explicitly. It likely can, but was never intended to.
writeHead has been around since that first commit, but for reasons lost to time wasn't used

Idk that I can say that issue #122 "supporting http2" is closed after landing #170, because I personally haven't reviewed the code or tested for http2 edgecases.

However, removing an http internal to replace w/ a public interface which is equivalent is 💯

It doesn't look like _implicitHeader implementation has changed much since Node v0.4.12:
https://github.com/nodejs/node/blob/v0.4.12/lib/http.js#L796

Here it is in v23:
https://github.com/nodejs/node/blob/v23.1.0/lib/_http_server.js#L336

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jonchurch
jonchurch approved these changes Nov 10, 2024
View reviewed changes
@jonchurch

jonchurch commented Nov 10, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This history is long w/ 19 commits, @bjohansebas when/if you merge I'd suggest squashing via the dropdown to keep the history clean

history.md isn't updated in this PR, we've talked about dropping that file (at least blake is planning to do so) but just a reminder in case you want to make sure you don't forget changelog update

bjohansebas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas merged commit b7d5d77 into expressjs:master Nov 13, 2024
@bjohansebas bjohansebas mentioned this pull request Jan 8, 2025
release: 1.8.0 #212
Merged
@nobodysfool nobodysfool mentioned this pull request Jul 18, 2025
Bump on-headers and compression userfrosting/UserFrosting#1291
Merged
@n-dering n-dering mentioned this pull request Jul 19, 2025
Bump on-headers and compression n-dering/snake_react#2
Open
@bjohansebas bjohansebas mentioned this pull request Jan 26, 2026
feat: enable compression middleware for http/2 webpack/webpack-dev-server#5638
Merged
@mtrezza mtrezza mentioned this pull request Oct 25, 2026
fix: Bump compression from 1.7.3 to 1.8.2 parse-community/relay-examples#32
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bjohansebas bjohansebas bjohansebas approved these changes
@jonchurch jonchurch jonchurch approved these changes
@UlisesGascon UlisesGascon Awaiting requested review from UlisesGascon
@lamweili lamweili Awaiting requested review from lamweili

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@bjohansebas bjohansebas

Labels

enhancement

Projects

None yet

Milestone

1.8.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@Icehunter @dougwilson @valoricDe @lamweili @bjohansebas @jonchurch @maritz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.