Skip to content

Stream update progress as it arrives, and count the final reboot as success - #23

Open
mullinmax wants to merge 4 commits into
mainfrom
claude/project-thread-wfq7z4
Open

mullinmax wants to merge 4 commits into
mainfrom
claude/project-thread-wfq7z4

Conversation

@mullinmax

Copy link
Copy Markdown
Contributor

Requested by Maxwell · project thread

Before: apply_update(progress=...) against a real board called progress once, at the very end, with every record glued into a single {"log": ...}, and then raised DeviceUnreachableError even though the update worked. Origin showed no progress and marked a successful update as failed.

After: progress fires for each record as the board sends it, and a connection lost after the board says "Update complete" returns normally. Losing the board any earlier still raises.

Three causes, all visible in the firmware (vector/src/common/backend.py and phew/server.py): the board writes {"percent": 2}{"percent": 3} back to back with no newline, sends no length, and reboots without closing the socket. The library split on newlines, read in 4096 byte buffers, and treated the reboot as an error.

How

  • machine._iter_records decodes with json.JSONDecoder.raw_decode, so back to back objects, newline separated objects and plain text lines all parse. It replaces _iter_lines.
  • HttpTransport.stream reads with urllib3's read1, which returns whatever has arrived, and falls back to byte reads on urllib3 older than 2.3. Raw urllib3 and socket errors map to the same DeviceUnreachableError / DeviceTimeoutError as before.
  • apply_update swallows a TransportError only once a record containing "Update complete" has been seen.
  • Version 0.5.1.

Tests cover back to back records arriving across chunks, a UTF-8 character split across chunks, the reboot after completion, a drop midway, the typed raw read errors, and a real socket that holds back its second record to prove the first one is delivered early.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XmBYzaorDTZcj96eHCBC35


Generated by Claude Code

…uccess

A Vector board writes its update progress as JSON objects back to back
with no newline between them, closes without a length, and reboots
without closing the connection once the update is written. apply_update
split on newlines and read in 4096 byte buffers, so the progress callback
fired once at the very end with everything glued into one "log" line, and
the reboot then surfaced as DeviceUnreachableError: a successful update
reported as a failure.

- Decode records with a raw JSON decoder, so back to back objects,
  newline separated objects and plain text lines all work.
- HTTP streams hand back what has arrived (urllib3 read1) instead of
  waiting for a full buffer; raw urllib3 errors map to the same typed
  transport errors as before.
- A connection lost after the board has said "Update complete" returns
  the records normally; lost any earlier, it still raises.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmBYzaorDTZcj96eHCBC35
@mullinmax mullinmax self-assigned this Oct 11, 2026
Closing a socket with request bytes still unread makes the kernel send a
reset, so on CI the body arrived after the headers and the clean close
became a DeviceUnreachableError.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmBYzaorDTZcj96eHCBC35
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmBYzaorDTZcj96eHCBC35
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Coverage report

✅

Total coverage: 100.00% (0.00% vs base 100.00%)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmBYzaorDTZcj96eHCBC35

This branch has not been deployed

No deployments
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.

2 participants