Skip to content

fix(browser): evict each failed load and drop writes stuck behind an eviction - #37

Merged
leoisadev1 merged 1 commit into
mainfrom
bg0/review-followups-3
Sep 29, 2026
Merged

leoisadev1 merged 1 commit into
mainfrom
bg0/review-followups-3

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Devin left two findings on #36 after it merged.

The corrupt-model eviction was keyed to the load's rejection object. A retry is a new load, but if the runtime rejected it with the same error object, the lookup returned the first eviction and skipped deleting the retry's corrupt download, which stayed cached for later visits. Evictions are now keyed to the shared engine load itself. Every caller that joined a load still shares one eviction, and each retry gets its own.

A cache write that starts during an eviction waits for that eviction's delayed delete. If an earlier write hangs, the eviction never finishes, and each later write held a model-sized response forever without caching it. The write now waits at most 30 seconds and is then dropped. A dropped write only means the next visit downloads the model again.

Root bun run lint, typecheck, test and build pass. The new tests for a retry that reuses its error object and for a write stuck behind a slow eviction fail on main and pass here. No real browser or device was exercised.

Created with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code


Devin Review

…eviction

Evictions are now keyed to the shared engine load rather than its
rejection, so a retry that rejects with a reused error object still
evicts its own download. A cache write waiting behind an eviction is
dropped after 30 seconds instead of holding its response indefinitely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bg0-web Ready Ready Preview Sep 29, 2026 4:36pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
bg0-docs Skipped Skipped Sep 29, 2026 4:36pm UTC

Request Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Devin Review

Comment thread packages/browser/src/index.ts
@leoisadev1
leoisadev1 merged commit 6c8a2d7 into main Sep 29, 2026
6 checks passed
@leoisadev1
leoisadev1 deleted the bg0/review-followups-3 branch September 29, 2026 16:38
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Fixes cache eviction and write timeout handling in browser model loading.

Not safe to merge until a stalled inference can be recovered or the user is told to reload.

What we checked:

  • T-Rex produced a proof for a posted P1 finding and linked it to the review comment. T-Rex
  • T-Rex produced a second proof for another P1 finding; there are no artifacts attached to this proof. T-Rex
  • For contract validation, T-Rex documented the control-versus-hung behavior of stall/retry, noting that abort leads to Download PNG while pending retries reuse the engine and stall, then return to Try again. T-Rex

Summary

The PR improves model-cache eviction and recovery after failed loads. One blocking gap remains: if desktop inference stops responding, Try again can reuse the same blocked engine and stall again.

Reviews (1) · Last reviewed commit: "fix(browser): evict each failed load and..."

@greptile-apps

greptile-apps Bot commented Sep 29, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Retry reuses stalled engine apps/web/src/features/remover/remover.tsx:324 ▶

    If desktop model inference stops responding, this timeout aborts the removal and offers Try again, but it neither stops the inference nor retires its cached engine. The retry can wait behind the still-pending inference and time out again. This needs an engine-recovery path or a reload-required message before merging.

  • P1 Stalled inference leaves Try again using the same blocked engine ▶

    • Bug
      • The stall timer shows a retryable error and aborts the first caller, but an immediate retry can enter the cached model while its original inference remains unresolved. Under a serialized inference queue, the retry stalls too. This affects desktop WebGPU or WASM runs when inference stops responding.
    • Cause
      • The new abort at apps/web/src/features/remover/remover.tsx:324 does not interrupt the awaited model inference at packages/browser/src/index.ts:758–759. Cancellation is raced against engine loading at packages/browser/src/index.ts:677, not inference; the engine remains in the load cache.
    • Fix
      • On an inference stall, retire or otherwise isolate the affected engine and ensure a retry cannot queue behind its unresolved execution; provide a reload-required outcome if safe recovery is impossible.

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – bg0-web — c7dd044a Deployed Sep 29, 2026 by vercel[bot]
Preview – bg0-docs — c7dd044a Deployed Sep 29, 2026 by vercel[bot]
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