[PR #23] [MERGED] Submit form: read the picked file first, say to pick it again when it changed #25

Closed
opened 2026-11-03 04:02:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-site/pull/23
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: fix/mod-submit-unreadable-file


📝 Commits (2)

  • a38ed99 Submit form: read the picked file before sending, name it when it can't be read
  • c5165e9 Merge remote-tracking branch 'origin/main' into fix/mod-submit-unreadable-file

📊 Changes

3 files changed (+56 additions, -6 deletions)

View changed files

📝 src/mods-submit.js (+11 -5)
📝 src/mods.js (+29 -0)
📝 src/mods.test.mjs (+16 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

The bug

A signed-in contributor sending a mod on /mods/submit got "The service didn't answer. Try again in a minute." ten times.

Railway's http logs for the site service show the reason. All ten requests (2026-10-30 13:06:31–13:09:00Z, Chrome 156 on Windows) ended with 499, "client has closed the request before the server could send a response", after 1 ms. The browser cut each request right after its headers, so no byte of the file was sent and the registry never saw it. The request's own fetch threw, which is the form's catch. The last submission that worked (03:50Z) took 6.2 s and got its 200.

That's how Chrome behaves when a picked file changed on disk after it was picked (ERR_UPLOAD_FILE_CHANGED): a mod rebuilt while the form is open, a file moved, or a file locked by another program. I reproduced it in Chromium 1248 (playwright, local server):

unchanged file: status 200 | read 200000 bytes
rebuilt file:   fetch threw TypeError: Failed to fetch | read threw NotReadableError: The requested file could not be read…
server saw: [ only the first request ]

Clicking Submit again resends the same stale reference, so every retry failed in 1 ms. Five of the ten came within one second.

The fix

  • readPicked() (in mods.js, unit-tested) reads the file and the .minisig before anything is sent. The form then uploads those bytes.
  • A file the browser can no longer read gets this message: "Your browser can't read any more: it changed, moved or is open in another program since you picked it (a new build?). Pick it again, then submit."
  • A file over 64 MB (the registry's index::MAX_FILE) is refused before the upload.
  • Reading the signature used to happen outside the try, so a failure there showed nothing at all. It is now covered too.
  • A real network failure still gets "The service didn't answer", now with "check your connection".

Checked in Chromium on the built page against a stub service:

unchanged: Submitted. Follow the review in its pull request… (service got 1)
rebuilt:   Your browser can't read coords_hud-0.1.0.hmod any more: … Pick it again, then submit. (service got 1)
re-picked: Submitted. Follow the review in its pull request… (service got 2)

npm test: 57 pass, 0 fail. node build.mjs builds.

The registry's side (drain the body before refusing, JSON 413, a clear "GitHub is slow" error) is a separate PR in horizon-rust/horizon.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-site/pull/23 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mod-submit-unreadable-file` --- ### 📝 Commits (2) - [`a38ed99`](https://github.com/horizon-rust/horizon-site/commit/a38ed9975f008ac3bbd1801393d05b4811620cf1) Submit form: read the picked file before sending, name it when it can't be read - [`c5165e9`](https://github.com/horizon-rust/horizon-site/commit/c5165e9039d7a8b168bcf40a4946cc6e97c08133) Merge remote-tracking branch 'origin/main' into fix/mod-submit-unreadable-file ### 📊 Changes **3 files changed** (+56 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/mods-submit.js` (+11 -5) 📝 `src/mods.js` (+29 -0) 📝 `src/mods.test.mjs` (+16 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## The bug A signed-in contributor sending a mod on /mods/submit got "The service didn't answer. Try again in a minute." ten times. Railway's http logs for the `site` service show the reason. All ten requests (2026-10-30 13:06:31–13:09:00Z, Chrome 156 on Windows) ended with **499, "client has closed the request before the server could send a response", after 1 ms**. The browser cut each request right after its headers, so no byte of the file was sent and the registry never saw it. The request's own `fetch` threw, which is the form's `catch`. The last submission that worked (03:50Z) took 6.2 s and got its 200. That's how Chrome behaves when a picked file changed on disk after it was picked (`ERR_UPLOAD_FILE_CHANGED`): a mod rebuilt while the form is open, a file moved, or a file locked by another program. I reproduced it in Chromium 1248 (playwright, local server): ``` unchanged file: status 200 | read 200000 bytes rebuilt file: fetch threw TypeError: Failed to fetch | read threw NotReadableError: The requested file could not be read… server saw: [ only the first request ] ``` Clicking Submit again resends the same stale reference, so every retry failed in 1 ms. Five of the ten came within one second. ## The fix - `readPicked()` (in `mods.js`, unit-tested) reads the file and the `.minisig` before anything is sent. The form then uploads those bytes. - A file the browser can no longer read gets this message: "Your browser can't read <name> any more: it changed, moved or is open in another program since you picked it (a new build?). Pick it again, then submit." - A file over 64 MB (the registry's `index::MAX_FILE`) is refused before the upload. - Reading the signature used to happen outside the `try`, so a failure there showed nothing at all. It is now covered too. - A real network failure still gets "The service didn't answer", now with "check your connection". Checked in Chromium on the built page against a stub service: ``` unchanged: Submitted. Follow the review in its pull request… (service got 1) rebuilt: Your browser can't read coords_hud-0.1.0.hmod any more: … Pick it again, then submit. (service got 1) re-picked: Submitted. Follow the review in its pull request… (service got 2) ``` `npm test`: 57 pass, 0 fail. `node build.mjs` builds. The registry's side (drain the body before refusing, JSON 413, a clear "GitHub is slow" error) is a separate PR in horizon-rust/horizon. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:02:27 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-site#25
No description provided.