question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.27.4

Plugin version

4.0.1

Node.js version

16.13.1

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

12.0.1

Description

Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
  at new NodeError (node:internal/errors:371:5)
  at Duplexify.onclose (node:internal/streams/end-of-stream:135:30)
  at Duplexify.emit (node:events:402:35)
  at Duplexify.emit (node:domain:475:12)
  at Duplexify._destroy (/Users/gajus/Documents/dev/contra/contra-web-app/node_modules/duplexify/index.js:199:8)
  at /Users/gajus/Documents/dev/contra/contra-web-app/node_modules/duplexify/index.js:182:10
  at processTicksAndRejections (node:internal/process/task_queues:78:11)

Steps to Reproduce

This appears to happen when request is aborted while still serving the file.

Expected Behavior

Should produce a warning, but not an uncaught error.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:36 (21 by maintainers)

github_iconTop GitHub Comments

12reactions
ilya-adnymicscommented, Aug 10, 2022

Too late to the party, but Google sent me here, so I’ll post a comment in case someone else would end up here as well.
Got the same error after migrating to fastify 4 and @fastify/compress 6. I didn’t want to remove @fastify/compress as I find it super nice (although the error was gone after I tried commenting it out 🤷‍♂️). What fixed it for me is following this instructions from fastify Migration guide:

In some situations, like when a response is sent asynchronously or when you’re just not explicitly returning a response, you’ll need to return the reply argument from your router handler.

So basically repace

  ...
  reply.send(page)
  return

with

  return reply.send(page)

After this, my requests started working, compression is working as well.

2reactions
SimenBcommented, Jul 4, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

npm ERR! premature close when using npm install
In my case, the package I was trying to install had a dependency on a Git repository that didn't have a package.json defined...
Read more >
"premature close" error during npm install from git url #1 - GitHub
I know/see, that this repo doesn't have package.json, and I do npm install https://github.com/coryetzkorn/state-svg-defs.git Also tried ssh.
Read more >
[Gatling 3.0.-RC2] Premature close - Google Groups
You get a "Premature close": either when we've received a partial response, then the connection was closed; or we've reach the maximum number...
Read more >
Premature closure? Not so fast - BMJ Quality & Safety
When a physician makes a challenging diagnosis with just a few pieces of information, she is called a brilliant diagnostician. If her diagnosis...
Read more >
Premature Closure: Was It Just Syncope? | PSNet
Premature closure — the acceptance of a diagnosis before it has been objectively established and alternative diagnoses have been fully ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found