HarperFast / HarperFast/harper-pro

Blob receive: uncaughtException from read-timeout and write-after-end race during replication

Open
#195 0 comments 0 reactions 1 assignee Claimed by @kriszyp View on GitHub
area:replication bug from-jira
Dominant language
JavaScript
Stars
3
Forks
0
Avg merge
1d 21h
Merged PRs (30d)
80

Description

**Investigative.** Two related errors during replication blob transfer, both surfacing as `uncaughtException`:

## Error 1: Blob read timeout (receive side)

```
uncaughtException Error: Blob error: Error: File read timed out
at WebSocket. (.../threadServer.js:23:9590)
at Receiver._write (.../ws/lib/receiver.js:94:10)
```

Plus: `Timeout waiting for blob stream to finish for record unknown from [redacted-host]`

## Error 2: Write-after-end race on blob PassThrough

```
uncaughtException Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at PassThrough.Writable.end (node:internal/streams/writable:611:17)
at WebSocket. (.../threadServer.js:23:9624)
at Receiver._write (.../ws/lib/receiver.js:94:10)
```

The `ERR_STREAM_WRITE_AFTER_END` suggests the WS receiver is writing a blob chunk to a PassThrough stream that has already been `.end()`-ed — a race between stream teardown and WS message delivery.

## Status

Both errors surface as `uncaughtException` via `Receiver._write` — same escaping-error class fixed in related commits. "Currently blocked because we have no known way to reproduce" (from original Jira description).

## Relation to other work

- [HarperFast/harper-pro#158](https://github.com/HarperFast/harper-pro/issues/158) — CORE-3047 (same `uncaughtException` blob-timeout class, from the *sending* side; filed as "verify on current builds")
- Commits `22f8777` and `a686a55` fixed related blob-save uncaughtExceptions in the receive path — verify if these also address the `ERR_STREAM_WRITE_AFTER_END` pattern or only the `.catch()` on save promises.

## Acceptance criteria

- `ERR_STREAM_WRITE_AFTER_END` on blob PassThrough is caught/guarded so it cannot reach `uncaughtException`.
- Blob read timeout on the receiving end is handled gracefully (same as CORE-3047 sends side).
- Repro recipe documented once found.

---

🤖 Filed by Claude on behalf of Kris.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.