{"record":{"id":"9aab035b8b2e01e1","repo":"honojs/hono","slug":"this-context-has-no-executioncontext","errorCode":null,"errorMessage":"This context has no ExecutionContext","messagePattern":"This context has no ExecutionContext","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/context.ts","lineNumber":395,"sourceCode":"  get event(): FetchEventLike {\n    if (this.#executionCtx && 'respondWith' in this.#executionCtx) {\n      return this.#executionCtx\n    } else {\n      throw Error('This context has no FetchEvent')\n    }\n  }\n\n  /**\n   * @see {@link https://hono.dev/docs/api/context#executionctx}\n   * The ExecutionContext associated with the current request.\n   *\n   * @throws Will throw an error if the context does not have an ExecutionContext.\n   */\n  get executionCtx(): ExecutionContext {\n    if (this.#executionCtx) {\n      return this.#executionCtx as ExecutionContext\n    } else {\n      throw Error('This context has no ExecutionContext')\n    }\n  }\n\n  /**\n   * @see {@link https://hono.dev/docs/api/context#res}\n   * The Response object for the current request.\n   */\n  get res(): Response {\n    return (this.#res ||= createResponseInstance(null, {\n      headers: (this.#preparedHeaders ??= new Headers()),\n    }))\n  }\n\n  /**\n   * Sets the Response object for the current request.\n   *\n   * @param _res - The Response object to set.\n   */","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/honojs/hono/blob/e2740d5a1bd0b4254e517e3af8b60789284bc7bd/src/context.ts#L377-L413","documentation":"Hono's Context.executionCtx getter throws when no ExecutionContext was captured for the current request. Hono stores the ctx argument from fetch(request, env, ctx) in a private field; if the handler chain never received one (non-workers runtimes, direct app.request() calls), the getter has nothing to return and throws.","triggerScenarios":"Calling c.executionCtx.waitUntil(...) (or passThroughOnException) in a handler running under @hono/node-server, denoServe, Bun.serve, AWS Lambda adapters that don't forward an execution context, or in tests invoked via app.request() without the third executionCtx argument.","commonSituations":"Using waitUntil in code meant to be runtime-agnostic; upgrading/migrating from Wrangler dev to local Node dev where ctx is absent; unit tests calling app.request(path, env) without an ExecutionContext.","solutions":["Make waitUntil usage conditional: use c.executionCtx only when available, otherwise await the task or fire-and-forget","In tests, pass a stub ExecutionContext as the third argument to app.request(req, env, fakeCtx)","On Cloudflare Workers, ensure the ctx parameter is forwarded to Hono's fetch handler","Consider a helper that wraps task execution with a fallback when executionCtx is missing"],"exampleFix":"// before\nc.executionCtx.waitUntil(syncAnalytics()) // throws on Node.js\n\n// after\nconst task = syncAnalytics()\nif ('executionCtx' in c && c.executionCtx) {\n  // may still throw if absent; prefer explicit runtime check\n}\ntry {\n  c.executionCtx.waitUntil(task)\n} catch {\n  await task\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const hasExecutionContext = (c: Context): boolean => {\n  try {\n    c.executionCtx\n    return true\n  } catch {\n    return false\n  }\n}","tryCatchPattern":"try {\n  c.executionCtx.waitUntil(task)\n} catch {\n  // No ExecutionContext — run inline or fire-and-forget\n  void task.catch(() => {})\n}","preventionTips":["Guard waitUntil calls behind a runtime capability check","Use runtime-specific adapters that forward ctx","In tests, pass a fake ExecutionContext with waitUntil/passThroughOnException to app.request"],"tags":["hono","executioncontext","waituntil","cloudflare-workers","runtime"],"backgroundTag":"missing-execution-context","analyzedSha":"e2740d5a1bd0b4254e517e3af8b60789284bc7bd","analyzedAt":"2026-08-28T10:18:08.750Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}