fix(errors): treat detached-frame and early-main-frame as retryable#846
Merged
Conversation
`captureWithNavigationRetry` (wrapping page.pdf/screenshot) and `waitForReady` only wait-and-retry when `isContextDestroyed` matches. Two frame-lifecycle races on production 3.42.8 slipped through and failed the capture outright: Execution context is not available in detached frame or worker "<url>" (6/24h) Requesting main frame too early! (2/24h) The first is Chrome's other phrasing of a frame detaching mid-operation — the same condition as the already-matched "Attempted to use detached Frame", seen on SPAs (app.oviond.com) that client-navigate to a sub-route while a print targeting the old frame is in flight. The second is the inverse: an operation ran before the page's main frame attached. Both resolve once navigation settles, which is exactly what the retry does; a page that never navigates falls through when the bounded retry budget (timeouts.action) ends, same as today, just after a short wait. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesContext destruction detection
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
captureWithNavigationRetry(which wrapspage.pdf()/page.screenshot()) andwaitForReadyonly wait-for-navigation-and-retry whenisContextDestroyedreturns true. Two frame-lifecycle races on production 3.42.8 are not recognized, so they fail the capture immediately:Sample (
d53acca8, app.oviond.com — a SPA that navigates to a sub-route mid-print):Fix
Add both strings to
isContextDestroyed:Execution context is not available in detached frame— Chrome's other phrasing of a frame detaching mid-operation. Semantically identical to the already-matchedAttempted to use detached Frame; the retry (wait for navigation to settle, re-run on the new frame) is exactly right.Requesting main frame too early— the inverse race: the operation ran before the page's main frame attached. The frame arrives once navigation commits, so a settle-and-retry resolves it.The retry is bounded by
timeouts.action, so a genuinely broken page that never navigates falls through the same as today — just after a short wait instead of instantly.Confidence
Not equal between the two, stated plainly:
empty response/prerender:error(may never navigate). Included because it is a genuine transient lifecycle race and the retry cost is bounded, but it may just convert a fast fail into a short-delayed fail on broken pages rather than rescue them.Tests: 9 pass,
isContextDestroyedextended with both production strings.🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to error-string classification in the errors package; bounded retry behavior already exists for similar patterns.
Overview
Extends
isContextDestroyedso two production Chrome frame-lifecycle errors are treated like existing navigation/context teardown races and flow throughensureErrorascontextDisconnected(enabling settle-and-retry in PDF/screenshot paths instead of immediate failure).New matches:
Execution context is not available in detached frame(detached frame mid-operation) andRequesting main frame too early(main frame not attached yet). Comments on the helper are updated to describe both “torn down mid-flight” and “not yet attached” cases.Tests add positive cases for both production message strings.
Reviewed by Cursor Bugbot for commit 7235937. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit