Skip to content

Fix infinite save retry loop and method check bugs#472

Merged
makermelissa merged 1 commit intocircuitpython:mainfrom
makermelissa-piclaw:fix/save-retry-loop
Apr 23, 2026
Merged

Fix infinite save retry loop and method check bugs#472
makermelissa merged 1 commit intocircuitpython:mainfrom
makermelissa-piclaw:fix/save-retry-loop

Conversation

@makermelissa-piclaw
Copy link
Copy Markdown
Contributor

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 via setTimeout(saveFileContents, 2000) with no retry limit. This creates an infinite loop that:

Changes

js/script.js:

  • Add a retry counter with a max of 3 attempts for saveFileContents()
  • Show a clear error message to the user when retries are exhausted
  • Reset retry counter on successful save
  • Clear the retry timeout and reset counter on disconnect (prevents phantom retries after switching boards)
  • Fix missing closing quote in save failure message template literal

js/common/web-file-transfer.js:

  • Fix _isMethodAllowed(): method.toUpperCase was missing (), passing the function reference instead of calling it — so the method check always returned false
  • Add missing await on _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

  • Build passes with vite build
  • The Qualia-specific save failure likely has a firmware component too (display DMA contention during web server PUT), but this fix prevents the editor from looping forever regardless of the cause

- 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
Copy link
Copy Markdown
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and I see there were some bugs you caught that had been previously missed.

@makermelissa makermelissa merged commit 2db1006 into circuitpython:main Apr 23, 2026
1 check passed
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.

Cannot Save code.py Edits on Adafruit Qualia ESP32-S3 for TTL RGB-666 Displays

2 participants