Repository navigation
Conversation
…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
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
Coverage report✅ Total coverage: 100.00% (0.00% vs base |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Maxwell · project thread
Before:
apply_update(progress=...)against a real board calledprogressonce, at the very end, with every record glued into a single{"log": ...}, and then raisedDeviceUnreachableErroreven though the update worked. Origin showed no progress and marked a successful update as failed.After:
progressfires 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.pyandphew/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_recordsdecodes withjson.JSONDecoder.raw_decode, so back to back objects, newline separated objects and plain text lines all parse. It replaces_iter_lines.HttpTransport.streamreads with urllib3'sread1, 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 sameDeviceUnreachableError/DeviceTimeoutErroras before.apply_updateswallows aTransportErroronly once a record containing "Update complete" has been seen.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