Skip to content

fix: resolve premature close error logging (issue #382)#386

Merged
mcollina merged 1 commit intomainfrom
fix/issue-382-premature-close
Apr 3, 2026
Merged

fix: resolve premature close error logging (issue #382)#386
mcollina merged 1 commit intomainfrom
fix/issue-382-premature-close

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented Apr 1, 2026

Description

Fixes #382 - Removes spurious "premature close" error logging when clients disconnect during compressed streaming responses.

Changes

  1. Fixed premature close error logging (issue @fastify/compress: "premature close" errors in the onSend hook path #382)

    • The onEnd callback now filters out "premature close" errors
    • Client disconnection is a normal, expected event that Fastify handles gracefully
    • These errors were being logged at error level (50) unnecessarily
  2. Replaced pump/pumpify with native Node.js stream APIs

    • pumpstream.pipeline (built-in since Node.js 15)
    • pumpifystream.compose (built-in since Node.js 18)
    • Removed pump and pumpify from dependencies

Testing

  • All 177 existing tests pass
  • Added 3 new regression tests in test/regression/issue-382.test.js:
    • Global compression path client disconnects
    • reply.compress() path client disconnects
    • Verification that actual errors are still logged

Impact

  • Breaking change: None
  • Dependency changes: Removes pump and pumpify (replaced by native APIs)
  • Behavior change: No more error-level logs for client disconnections during streaming

…lose logging

- Replace pump with stream.pipeline for stream piping
- Replace pumpify with stream.compose for stream composition
- Remove pump and pumpify dependencies
- Fix issue #382: suppress premature close error logging on client disconnect
- Add regression tests for client disconnect scenarios

The premature close error is expected when clients disconnect mid-response
and should not be logged at error level since Fastify handles this gracefully.

Refs: #382
@mcollina mcollina requested review from Eomm, climba03003 and gurgunday and removed request for climba03003 April 1, 2026 09:14
@mcollina mcollina merged commit 840d6c4 into main Apr 3, 2026
17 checks passed
@mcollina mcollina deleted the fix/issue-382-premature-close branch April 3, 2026 21:45
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.

@fastify/compress: "premature close" errors in the onSend hook path

2 participants