Skip to content

fix(backend): race condition in hashing_stream#2263

Merged
KernelDeimos merged 1 commit intomainfrom
eric/2619_potential-upload-stuck-fix
Jan 10, 2026
Merged

fix(backend): race condition in hashing_stream#2263
KernelDeimos merged 1 commit intomainfrom
eric/2619_potential-upload-stuck-fix

Conversation

@KernelDeimos
Copy link
Copy Markdown
Contributor

Based on a stack trace from production and manual static analysis, it appears that a race condition occurs within hashing_stream intermittently. The conditions that cause this issue might be heavy backpressure. The source stream emits the 'end' event before stream.Transform's transform callback has had a chance to process all of the chunks, which results in an incorrect order in calling methods on the typeof crypto.createHash() object.

It would appear that source.pipe(stream) is not able to propagate errors from Transform because the chain was simply broken and upload would get stuck (if this was indeed the cause of upload getting stuck, which seems likely but not conclusive)

Based on a stack trace from production and manual static analysis, it
appears that a race condition occurs within hashing_stream
intermittently. The conditions that cause this issue might be heavy
backpressure. The source stream emits the 'end' event before
stream.Transform's transform callback has had a chance to process all of
the chunks, which results in an incorrect order in calling methods on
the `typeof crypto.createHash()` object.

It would appear that `source.pipe(stream)` is not able to propagate
errors from Transform because the chain was simply broken and upload
would get stuck (if this was indeed the cause of upload getting stuck,
which seems likely but not conclusive)
@KernelDeimos KernelDeimos merged commit 8e418a1 into main Jan 10, 2026
4 checks passed
@jelveh jelveh deleted the eric/2619_potential-upload-stuck-fix branch May 1, 2026 20:06
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