SDK send queue retries a dead serial port forever, and fragments its own error grouping
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 57/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- backend
Research direction
Start in packages/sdk/src/core/queue/Queue.ts and inspect sendPacket, focusing on how failed writes affect the queue and how errors are logged. Reproduce or test a failed write, including a closed or lost stream, and verify retries stop and packet IDs no longer fragment the error message. The issue suggests capping attempts and grouping errors, but leaves the exact behavior to choose.
Written by the indexing model from the issue text.
Description
Two problems in packages/sdk/src/core/queue/Queue.ts, both visible in the
web flasher's telemetry, where this is the single largest source of error
volume by a wide margin — more than every other error in the project combined.
Raw counts are in Datadog (RUM, us5). The query is:
@type:error @service:meshtastic-web-flasher @error.message:*"Error sending packet"*
The loop never ends
In sendPacket:
while (this.queue.filter((p) => !p.sent).length > 0) {
const item = this.queue.filter((p) => !p.sent)[0];
if (item) {
await new Promise((resolve) => setTimeout(resolve, 200));
try {
await writer.write(item.data);
item.sent = true;
} catch (error) {
const err = error as { code?: string };
if (err?.code === "ECONNRESET" || err?.code === "ERR_INVALID_STATE") {
writer.releaseLock();
this.lock = false;
throw error;
}
console.error(`Error sending packet ${item.id}`, error);
}
}
}
item.sent is only set on success, so a failed write leaves the same item at
the head of the queue and the while condition still true. The loop retakes
the same item, waits 200 ms, fails again, and reports again — indefinitely.
The escape hatch does not fire for the failures that actually happen. It tests
err.code, but the observed errors are a TypeError and DOMExceptions:
TypeError: Cannot write to a CLOSED writable streamNetworkError: The device has been lost.NetworkError: Port has been closedUnknownError: An unknown system error has occurred.
None of those carry .code — DOMException exposes .name. So every
real-world "the device is gone" case falls through to the console.error and
loops. At 200 ms per attempt a tab left open reports the same packet tens of
thousands of times, and individual sessions in Datadog do exactly that.
All four of these are terminal: the port is closed or the device is unplugged.
No number of retries fixes them.
The packet ID is in the message string
console.error(\Error sending packet ${item.id}`, error)` interpolates the ID,
so one fault becomes thousands of distinct message strings. Datadog groups by
message, so a single stuck session fragments into thousands of separate
issues rather than one. That is most of why this went unnoticed: nothing
aggregates, and you cannot find it without a wildcard search.
Suggested fix
- Treat a write failure on a closed or lost stream as terminal. Match on
error.namefor theDOMExceptioncases, or simply give up on any write
failure after marking the item failed — the current allowlist will keep
missing cases as browsers change their error types. - Cap attempts per item regardless, so no failure mode can loop forever.
- Move the packet ID out of the message and into a structured field, so the
fault groups as one issue.
- Dominant language
- TypeScript
- Stars
- 861
- Forks
- 316
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 18
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from meshtastic/web
-
i18n
Difficulty 1/5 Under an hour Newbie friendliness 82/100
meshtastic/web#1187 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
meshtastic/web#1532 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 52/100
meshtastic/web#1504 ·
Maintainers usually reply within 1 day
-
[Bug]: Serial connection to nRF52 device (T1000-E) never loads; port opened without DTR assertedOpen
Difficulty 3/5 Half a day Newbie friendliness 45/100
meshtastic/web#1499 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
meshtastic/web#1498 ·
Maintainers usually reply within 1 day
Similar issues
-
P3
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug L3 level 1 needs-review wocs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
SatyamPandey-07/WorkSphere#10739 · 1 comment ·
Maintainers usually reply within 1 day
-
maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
assistant-ui/assistant-ui#10946 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
openclaw/openclaw#206303 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day