Skip to content

fix(browser): serialize concurrent download imports - #112

Open
kvnloo wants to merge 2 commits into
CopilotKit:mainfrom
kvnloo:fix/browser-imports-serialize
Open

kvnloo wants to merge 2 commits into
CopilotKit:mainfrom
kvnloo:fix/browser-imports-serialize

Conversation

@kvnloo

@kvnloo kvnloo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Problem

BrowserService.imports() is the only mutating per-session browser operation that does not use the existing serial(id) queue.

The download dedupe path is check-then-act:

  1. look for browser-downloads/<downloadId>;
  2. if missing, fetch bytes and import a file;
  3. persist the dedupe row.

Two concurrent import requests can both pass step 1 and import the same download twice, leaving duplicate file rows/orphaned bytes.

Change

Route imports() through the existing per-session serial queue and move the current implementation into importsOwned().

The second caller then observes the first caller's dedupe row and returns the same signed file.

Regression

A focused test races two imports for one PDF download against a stub worker and asserts:

  • both callers receive one file;
  • both receive the same file ID;
  • exactly one file row exists.

No download format, signing, or browser navigation behavior changes.

This branch has not been deployed

No deployments
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.

1 participant