Fix infinite save retry loop and method check bugs#472
Merged
makermelissa merged 1 commit intocircuitpython:mainfrom Apr 23, 2026
Merged
Fix infinite save retry loop and method check bugs#472makermelissa merged 1 commit intocircuitpython:mainfrom
makermelissa merged 1 commit intocircuitpython:mainfrom
Conversation
- Add retry limit (3 attempts) to saveFileContents() to prevent infinite retry loop when file writes fail. Shows error message after retries exhausted instead of silently retrying forever. This fixes the 'reloading every 1-2 seconds' behavior reported in circuitpython#460. - Clear save retry timeout on disconnect to prevent retries from continuing after switching boards or disconnecting. - Fix _isMethodAllowed() missing parentheses on toUpperCase call (was passing function reference instead of calling it). - Add missing await on _isMethodAllowed() call in _fetch() so the method permission check actually evaluates the result. - Fix missing closing quote in save failure message template literal. Fixes circuitpython#460
makermelissa
approved these changes
Apr 23, 2026
Collaborator
makermelissa
left a comment
There was a problem hiding this comment.
Looks good and I see there were some bugs you caught that had been previously missed.
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.
Summary
Fixes #460 — Cannot Save code.py Edits on Adafruit Qualia ESP32-S3
The Problem
When saving a file fails (e.g., due to a connection issue or board being busy),
saveFileContents()catches the error and retries viasetTimeout(saveFileContents, 2000)with no retry limit. This creates an infinite loop that:Changes
js/script.js:
saveFileContents()js/common/web-file-transfer.js:
_isMethodAllowed():method.toUpperCasewas missing(), passing the function reference instead of calling it — so the method check always returnedfalseawaiton_isMethodAllowed()call in_fetch()so the permission check result is actually evaluated (previously the unawaited Promise was always truthy, making the check dead code)Testing
vite build