moleculer icon indicating copy to clipboard operation
moleculer copied to clipboard

Heartbeat not sent while streaming large files, leads stream closure in 0.14.35

Open MichaelErmer opened this issue 7 months ago • 1 comments

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [x] I am running the latest version
  • [x] I checked the documentation and found no answer
  • [x] I checked to make sure that this issue has not already been filed
  • [x] I'm reporting the issue to the correct repository

Current Behavior

If a large file is streamed and processing takes longer than heartbeatTimeout the stream now gets closed due to changes in https://github.com/moleculerjs/moleculer/pull/1306

Earlier versions didn't care, because the node would just reconnect after the stream ended, within cleanOfflineNodesTimeout so they would then continue to function as intended.

Expected Behavior

Steam packages should be accounted as heartbeat or heartbeat needs to work whilst streaming.

Failure Information

Steps to Reproduce

Node A: have a action accept a Passthrough

Node B: send large file to action on A

After the heartbeatTimeout node B receives the error Request stream closed by Node A

Reproduce code snippet

Can not reproduce the discovery being enabled in sandbox, but this example should cover it if used with nats https://codesandbox.io/p/devbox/moleculer-sample-forked-3ncjxd?file=%2Findex.js

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Moleculer version: 0.14.35
  • NodeJS version: 20
  • Operating System: yes
  • Transport: NATS

Failure Logs

Request stream closed by Node A

MichaelErmer avatar May 23 '25 11:05 MichaelErmer

Possible solution would be to handle stream packages as heartbeats (make configurable) or disable heartbeat checks while stream is open.

MichaelErmer avatar May 23 '25 11:05 MichaelErmer