Skip to content

Avoid Safari/WebKit stalls during chunked ROM uploads#3382

Merged
gantoine merged 4 commits into
masterfrom
copilot/fix-safari-webkit-upload-issues
May 17, 2026
Merged

Avoid Safari/WebKit stalls during chunked ROM uploads#3382
gantoine merged 4 commits into
masterfrom
copilot/fix-safari-webkit-upload-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

Chunked ROM uploads could stall after the first few PUT /api/roms/upload/{id} requests in Safari/WebKit, while the same flow completed normally in Chromium-based browsers. The issue was isolated to the frontend upload path rather than the server-side chunk assembly flow.

  • Chunked upload behavior

    • Detect Safari/WebKit-style user agents during chunked ROM uploads.
    • Skip axios onUploadProgress for those browsers, which avoids the WebKit-specific upload stall point.
    • Keep the existing per-chunk request, retry, cancel, and complete flow unchanged.
  • Progress reporting

    • Preserve progress updates for Chromium-based browsers using the existing upload progress callback.
    • For Safari/WebKit, update progress when each chunk finishes so uploads still show forward progress without relying on WebKit upload-progress events.
  • Scope

    • Limit the change to frontend/src/services/api/rom.ts.
    • Leave manual uploads and backend upload endpoints untouched.
const trackChunkUploadProgress = shouldTrackChunkUploadProgress();

await api.put(`/roms/upload/${upload_id}`, chunk, {
  headers: {
    "Content-Type": "application/octet-stream",
    "X-Chunk-Index": i.toString(),
  },
  timeout: 120000,
  ...(trackChunkUploadProgress && {
    onUploadProgress: (progressEvent: AxiosProgressEvent) => {
      const chunkFraction = progressEvent.progress ?? 0;
      const overall = ((i + chunkFraction) / totalChunks) * 100;
      uploadStore.updateChunkProgress(file.name, overall, file.size, progressEvent.rate);
    },
  }),
});

uploadStore.updateChunkProgress(file.name, ((i + 1) / totalChunks) * 100, file.size);

Copilot AI linked an issue May 16, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/41c15553-6e97-45ca-be3d-589c2f07589e

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix uploads in Safari/WebKit for large ROM files Avoid Safari/WebKit stalls during chunked ROM uploads May 16, 2026
Copilot AI requested a review from gantoine May 16, 2026 21:56
@gantoine
Copy link
Copy Markdown
Member

@copilot can you confirm webkit is the issue here?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot can you confirm webkit is the issue here?

Not definitively. What I can confirm is that the failing path is browser-engine-specific: same server/upload flow works in Chromium, fails in Safari/WebKit, and the only client-side behavior I changed is Safari’s onUploadProgress path for chunked uploads. There is upstream evidence that Safari has axios upload-progress issues (axios/axios#6500), so this is a targeted mitigation for that Safari/WebKit-specific path rather than proof that WebKit alone is the root cause.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bugs.webkit.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • developer.mozilla.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@gantoine gantoine marked this pull request as ready for review May 16, 2026 23:12
Copilot AI review requested due to automatic review settings May 16, 2026 23:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Works around a Safari/WebKit-specific stall observed during chunked ROM uploads by skipping axios's onUploadProgress callback on WebKit browsers, while preserving forward progress updates by emitting a per-chunk completion update.

Changes:

  • Add shouldTrackChunkUploadProgress() that returns false for WebKit user agents that are not Chromium-based.
  • Conditionally attach onUploadProgress to the chunk PUT request based on the above check.
  • Always emit a chunk-completion progress update after each successful PUT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/services/api/rom.ts Outdated
Comment thread frontend/src/services/api/rom.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • frontend/package-lock.json: Language not supported

@gantoine gantoine merged commit 016cc1c into master May 17, 2026
9 checks passed
@gantoine gantoine deleted the copilot/fix-safari-webkit-upload-issues branch May 17, 2026 00:07
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.

Safari/WebKit uploads fail

3 participants