Skip to content

fix: avoid search/embedding coalesce poison after last-waiter abort#1212

Merged
BigSimmo merged 11 commits into
mainfrom
cursor/pr1196-coalesce-main-4711
Jul 26, 2026
Merged

fix: avoid search/embedding coalesce poison after last-waiter abort#1212
BigSimmo merged 11 commits into
mainfrom
cursor/pr1196-coalesce-main-4711

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

Found while reviewing PR #1196 (now closed as superseded by #913 / current main). The same cancel/PDF defects were already on main.

When the last waiter disconnects from a coalesced search or query-embedding flight, the shared producer is aborted but the map entry stayed until the producer's .finally ran. A healthy same-key retry could join the dying promise and fail (AbortError / search HTTP 500) even though its own signal was live. Answer coalescing already recovered from foreign aborts; search/embed did not.

Also fixes fractional PDF render dimensions (100.5×100.5) being rejected by Number.isSafeInteger(pixels) and aborting the whole JS PDF fallback.

Verification

  • Focused Vitest: tests/openai-cache.test.ts, tests/pdf-extraction-budget.test.ts, tests/private-access-routes.test.ts163 passed
  • Pure-JS repro: node scripts/repro-coalesce-poison-race.mjs (buggy poisoned / fixed recovers)
  • Hosted required CI green on this PR (PR required SUCCESS)
  • UI verification not run: no UI/routing/styling changes

Risk and rollout

  • Risk: Low. Restores retry behavior after cancel; ceil-based pixel budgeting is slightly more permissive for fractional metadata but still capped by maxRenderPixels.
  • Rollback: Revert this PR.
  • Provider or production effects: None

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

RAG impact: no retrieval behaviour change — cancel coalescing + PDF render budget validation only

Open in Web Open in Cursor 

Delete dying search/embedding inflight map entries when the last waiter disconnects, and ceil fractional PDF render dimensions before the safe-integer pixel budget check.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a17b906-a65a-4007-b47a-36bd0660e828

📥 Commits

Reviewing files that changed from the base of the PR and between b2b31f9 and b88d69b.

📒 Files selected for processing (8)
  • docs/branch-review-ledger.md
  • scripts/repro-coalesce-poison-race.mjs
  • src/app/api/search/route.ts
  • src/lib/extractors/pdf-extraction-budget.ts
  • src/lib/openai.ts
  • tests/openai-cache.test.ts
  • tests/pdf-extraction-budget.test.ts
  • tests/private-access-routes.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/pr1196-coalesce-main-4711

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Jul 25, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Append ledger rows for the Bugbot/regression review of PR #1196 and the
main fix-forward in PR #1212.
BigSimmo and others added 3 commits July 25, 2026 23:22
Close without merge: tip is stale/conflicting and the remediation
family already landed on main; live coalesce/PDF fixes stay in #1212.
@BigSimmo
BigSimmo marked this pull request as ready for review July 25, 2026 15:28
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 25, 2026 15:28
@BigSimmo

Copy link
Copy Markdown
Owner Author

Hygiene review (2026-07-26): GitHub reports CONFLICTING/DIRTY and update-branch returned 422. Local merge-tree against origin/main needs a human sync in a worktree (do not force). This PR is the clean coalesce fix-forward — keep open, merge origin/main and resolve, then push. Not closing.

BigSimmo added a commit that referenced this pull request Jul 26, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve merge conflict and tell me if this is worth merging

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: d01352a096

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

cursoragent and others added 3 commits July 26, 2026 03:28
…e-main-4711

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo merged commit a9920e3 into main Jul 26, 2026
18 checks passed
@BigSimmo
BigSimmo deleted the cursor/pr1196-coalesce-main-4711 branch July 26, 2026 03:42
cursor Bot pushed a commit that referenced this pull request Jul 26, 2026
Append final land/close rows for the authorized open-PR triage:
closed unsafe audit tips #1255/#1253, and prlanded #1257/#1212/#1241/#1248/#1254/#1259.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
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.

2 participants