?reset=1: saving after erasing secrets writes a 0-byte file (follow-up to #19) #20

Open
opened 2026-11-24 02:42:18 +00:00 by eric · 3 comments
Owner

After opening with #reset=1 and unlocking, the secret fields are cleared as expected. Pressing the Save button to save to local disk then creates a file of 0 length, so the reset result can't be kept.

Expected: Save writes the full encrypted HTML with the secrets erased.

Actual: the file is created but is 0 bytes.

Repro:

  1. Open final-wishes.html, unlock.
  2. Add #reset=1 to the address and press Enter.
  3. Choose Erase on the banner (secret fields clear).
  4. Click Save and pick a location on local disk.
  5. The resulting file is 0 bytes.

Notes: not yet investigated. Look at save() in src/app.js (showSaveFilePicker handle reuse / writable close, and assemble() in src/template.js) after the reset path. Refs #19.

After opening with #reset=1 and unlocking, the secret fields are cleared as expected. Pressing the Save button to save to local disk then creates a file of 0 length, so the reset result can't be kept. **Expected:** Save writes the full encrypted HTML with the secrets erased. **Actual:** the file is created but is 0 bytes. **Repro:** 1. Open final-wishes.html, unlock. 2. Add #reset=1 to the address and press Enter. 3. Choose Erase on the banner (secret fields clear). 4. Click Save and pick a location on local disk. 5. The resulting file is 0 bytes. **Notes:** not yet investigated. Look at save() in src/app.js (showSaveFilePicker handle reuse / writable close, and assemble() in src/template.js) after the reset path. Refs #19.
Author
Owner

Chrome. No status message was noticed after the failed save. Not yet tried a plain save without #reset=1.

Investigation so far: could not reproduce in headless Chrome with a stubbed showSaveFilePicker (full 90,928-byte file written after unlock + #reset=1 banner). Save after reset uses the same save() path as any edit (src/app.js:685). Note save() returns silently on an AbortError (src/app.js:719), which would match 'no status message'. Next: user to try a plain save and check the DevTools console.

Chrome. No status message was noticed after the failed save. Not yet tried a plain save without #reset=1. Investigation so far: could not reproduce in headless Chrome with a stubbed showSaveFilePicker (full 90,928-byte file written after unlock + #reset=1 banner). Save after reset uses the same save() path as any edit (src/app.js:685). Note save() returns silently on an AbortError (src/app.js:719), which would match 'no status message'. Next: user to try a plain save and check the DevTools console.
Author
Owner

Cause found: Chrome created the empty file, then createWritable threw NotAllowedError ('The request is not allowed by the user agent or the platform in the current context'). This is Chrome refusing the chosen location (typically a protected folder such as Downloads, Documents or home), not the reset code; a plain save to that spot would fail the same way.

Fix (committed): save() now catches NotAllowedError/SecurityError on the write, clears the stored handle so the next Save re-prompts, downloads final-wishes.html as a fallback, and shows a status message explaining it. MAINTENANCE.md notes to save into a subfolder or the thumbdrive. Not yet verified in a real Chrome save dialog.

Cause found: Chrome created the empty file, then createWritable threw NotAllowedError ('The request is not allowed by the user agent or the platform in the current context'). This is Chrome refusing the chosen location (typically a protected folder such as Downloads, Documents or home), not the reset code; a plain save to that spot would fail the same way. Fix (committed): save() now catches NotAllowedError/SecurityError on the write, clears the stored handle so the next Save re-prompts, downloads final-wishes.html as a fallback, and shows a status message explaining it. MAINTENANCE.md notes to save into a subfolder or the thumbdrive. Not yet verified in a real Chrome save dialog.
Author
Owner

Update: not an app bug. Saving to ~/Documents/final-wishes.html also failed (0-byte file, same NotAllowedError). A bare test page with no app code (showSaveFilePicker then createWritable) fails identically on both http://localhost and file://, even for a tiny text file, so Chrome or the desktop is refusing the write.

Ruled out: file ownership/mounts (home folders owned by the user, root is rw ext4), snap/flatpak sandbox (normal .deb Chrome 157), enterprise policy (none), stored Chrome settings (file_system_write_guard/read_guard empty). Unusual: COSMIC on Wayland with the COSMIC/GTK xdg-desktop-portal file dialog; best guess, unconfirmed, is that the portal dialog hands Chrome a file it will not let the page write.

Unexplained: saving to a thumbdrive reportedly works; not yet checked how.

Pending decision (owner thinking it over): make download the default save and keep in-place save opt-in, versus keeping the current try-then-fall-back (613f039), versus investigating more (other browser, thumbdrive tests). Details in HANDOFF.md. Issue stays open.

Update: not an app bug. Saving to ~/Documents/final-wishes.html also failed (0-byte file, same NotAllowedError). A bare test page with no app code (showSaveFilePicker then createWritable) fails identically on both http://localhost and file://, even for a tiny text file, so Chrome or the desktop is refusing the write. Ruled out: file ownership/mounts (home folders owned by the user, root is rw ext4), snap/flatpak sandbox (normal .deb Chrome 157), enterprise policy (none), stored Chrome settings (file_system_write_guard/read_guard empty). Unusual: COSMIC on Wayland with the COSMIC/GTK xdg-desktop-portal file dialog; best guess, unconfirmed, is that the portal dialog hands Chrome a file it will not let the page write. Unexplained: saving to a thumbdrive reportedly works; not yet checked how. Pending decision (owner thinking it over): make download the default save and keep in-place save opt-in, versus keeping the current try-then-fall-back (613f039), versus investigating more (other browser, thumbdrive tests). Details in HANDOFF.md. Issue stays open.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eric/final-wishes#20
No description provided.