You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: defer NotifyDestroyed to frameNavigated to correctly cancel pre-navigation contexts
With Chrome's RenderDocument feature, executionContextCreated may fire before
frameNavigated. The previous approach of calling NotifyDestroyed in SetContext
caused premature cancellation: for evaluations that return a value before
navigation (e.g. window.location + return [42]), Chrome sends the callFunctionOn
response before frameNavigated, but SetContext fires when executionContextCreated
arrives (also before frameNavigated), cancelling the evaluation prematurely.
The correct fix: defer NotifyDestroyed to Frame_FrameNavigated, which fires
after Chrome sends callFunctionOn responses. Track the old context in SetContext
via _contextToDestroyOnNavigation so the frameNavigated handler destroys the
right (pre-navigation) context regardless of whether _context already points to
the new context. For the pure RenderDocument case (no context events), fall back
to destroying _context directly since it still holds the old context.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments