Skip to content

fix: call res.end() when socket is not writable to prevent HTTP/2 HEAD hang#1947

Open
guoyangzhen wants to merge 2 commits intokoajs:v2.xfrom
guoyangzhen:fix/http2-head-response
Open

fix: call res.end() when socket is not writable to prevent HTTP/2 HEAD hang#1947
guoyangzhen wants to merge 2 commits intokoajs:v2.xfrom
guoyangzhen:fix/http2-head-response

Conversation

@guoyangzhen
Copy link
Copy Markdown

Description

When ctx.writable is false (common with HTTP/2), the respond function returns early without calling res.end(), causing HEAD requests to hang indefinitely.

This was working in v2.16.0 but was accidentally dropped in v2.16.1 (the res.end() call was removed from the early return). Multiple users reported the regression (#1547).

Change

- if (!ctx.writable) return;
+ if (!ctx.writable) return res.end();

The master branch already has this fix. This backports it to v2.x.

Related

Fixes #1547

…D hang

When ctx.writable is false (common with HTTP/2), the respond function
returned early without calling res.end(), causing HEAD requests to hang
indefinitely.

This restores the behavior from v2.16.0 which was accidentally dropped
in v2.16.1.

Fixes koajs#1547
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant