{"record":{"id":"ae85b61e138dae29","repo":"microsoft/playwright","slug":"frame-does-not-yet-have-the-execution-context","errorCode":null,"errorMessage":"Frame does not yet have the execution context","messagePattern":"Frame does not yet have the execution context","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/playwright-core/src/server/frames.ts","lineNumber":635,"sourceCode":"    } finally {\n      this._raceAgainstEvaluationStallingEventsPromises.delete(promise);\n    }\n  }\n\n  nonStallingRawEvaluateInExistingMainContext(expression: string): Promise<any> {\n    return this.raceAgainstEvaluationStallingEvents(() => {\n      const context = this.existingContext('main');\n      if (!context)\n        throw new Error('Frame does not yet have a main execution context');\n      return context.rawEvaluateJSON(expression);\n    });\n  }\n\n  nonStallingEvaluateInExistingContext(expression: string, world: types.World): Promise<any> {\n    return this.raceAgainstEvaluationStallingEvents(() => {\n      const context = this._contextData.get(world)?.context;\n      if (!context)\n        throw new Error('Frame does not yet have the execution context');\n      return context.evaluateExpression(expression, { isFunction: false });\n    });\n  }\n\n  _recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle?: Frame) {\n    let isNetworkIdle = this._firedNetworkIdleSelf;\n    for (const child of this._childFrames) {\n      child._recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle);\n      // We require networkidle event to be fired in the whole frame subtree, and then consider it done.\n      if (!child._firedLifecycleEvents.has('networkidle'))\n        isNetworkIdle = false;\n    }\n    if (isNetworkIdle && !this._firedLifecycleEvents.has('networkidle')) {\n      this._firedLifecycleEvents.add('networkidle');\n      this.emit(Frame.Events.AddLifecycle, 'networkidle');\n      if (this === this._page.mainFrame() && this._url !== 'about:blank')\n        this.apiLog(`  \"networkidle\" event fired`);\n    }","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/frames.ts#L617-L653","documentation":"nonStallingEvaluateInExistingContext throws when the requested world's context is not yet present in the frame's context data. Unlike the main-context variant it covers any world (main or utility) and fires when that world has not been initialized.","triggerScenarios":"Calling nonStallingEvaluateInExistingContext for a world whose context data has no .context yet - common on freshly attached frames, frames whose utility world is not ready, or frames being torn down.","commonSituations":"Same as 311 plus utility-world scenarios: internal helper evaluations that run before the utility world is set up; operations queued during frame detachment.","solutions":["Use context(world) which awaits the world's contextPromise instead of the non-stalling variant.","Wait for the frame to reach a stable lifecycle state.","Skip the operation if the frame is being detached."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// Prefer the awaited context accessor\nconst ctx = await frame.context(world);","typeGuard":"function hasContext(frame: any, world: string): boolean {\n  return !!frame._contextData?.get(world)?.context;\n}","tryCatchPattern":"null","preventionTips":["Do not call the nonStalling* internal APIs from user code.","Guard new-frame operations behind a load-state wait."],"tags":["frames","execution-context","timing"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}