pingvin-share: 🐛 Bug Report: Premature close error

👟 Reproduction steps

When downloading large file (couple of GB) the download fails after few minutes. The docker throws:

[Nest] 47  - 12/08/2023, 12:47:07 PM   ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at ServerResponse.onclose (node:internal/streams/end-of-stream:159:30)
    at ServerResponse.emit (node:events:526:35)
    at emitCloseNT (node:_http_server:1023:10)
    at Socket.onServerResponseClose (node:_http_server:278:5)
    at Socket.emit (node:events:526:35)
    at TCP.<anonymous> (node:net:337:12)

Sometimes this happens several times before the file if finally downloaded.

👍 Expected behavior

Successful download regardless the file size.

👎 Actual Behavior

As described above.

🌐 Browser

Firefox, Chromium, Brave

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Comments: 68 (24 by maintainers)

Most upvoted comments

This should be fixed in v0.22.2. Feel free to reopen the issue if you encounter the bug again.

@stonith404 you should probably re-open this, unfortunately 😕

Thanks @axiomen and @sebasdt. This issue is really difficult the fix, because I’m still not sure where the problem is. But I’ll keep you up to date.

This bug is really strange. @axiomen has reported that it doesn’t occur anymore so I’ll close it again… If you notice the error again please comment here.

I’m reopening this as @axiomen has reported that the issue still exists.

I’m guessing whatever you run your VM on can’t tell apart free vs cached memory, so it reports that most of your memory is taken, while in reality 84% is cached (as shown with the free command). The cached part is probably the file you’re downloading cached directly in the memory.

I don’t think that’s the issue. I’ve tested it both remotely (host in one location, client in another) and locally (host and client on the same network). Actually, most of my tests have been run locally.

So I debugged this issue a bit further and I found out that the backend logs Premature close error if the the browser cancels the download. My guess is that the issue occurs when the network is unstable and the client devices gets disconnected for a short time.

For example I’m using a VPN and I was able to reproduce this issue with the VPN but if I disable the VPN the download works. My VPN isn’t really reliable because sometimes if I visit a website I get the error “Network has changed”.

Could this be the issue or are you guys sure that your connection on the server and client are stable?

Thanks @axiomen for your observations!

Could you guys test version v0.21.0 too? There aren’t any db migrations since then so you only have to change the Docker image tag to v0.21.0 .

The annoying part is I do not know at what version pingvin broke. (My backups don’t go back that far and the last monthly december was just purged.)

The last known working state was back in 9 Dec, Although it could be later.

I doubt it would be related to Firefox. It is rather NestJS issue. Other projects reports similar problems… Could we log some more to be able to pinpoint the issue? https://github.com/nestjs/nest/issues/12283