vercel/next.js · error · Error

Route ${workStore.route} used `io()` inside `after()` while

Error message

Route ${workStore.route} used `io()` inside `after()` while rendering. The `io()` function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after

What it means

Error "Route ${workStore.route} used `io()` inside `after()` while rendering. The `io()` function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after" thrown in vercel/next.js.

Source

Thrown at packages/next/src/server/request/io.ts:33

/**
 * This function allows you to indicate that the code following it performs
 * I/O or accesses dynamic data sources such as `new Date()` or `Math.random()`.
 *
 * During prerendering it will prevent the prerender from continuing past this
 * point, creating a dynamic boundary. Inside `"use cache"` scopes or during
 * a real request it resolves immediately.
 *
 * Unlike `connection()`, `io()` does not require an actual HTTP request and
 * can be used freely inside cache scopes and client components.
 */
export function io(): Promise<void> {
  const workStore = workAsyncStorage.getStore()
  const workUnitStore = workUnitAsyncStorage.getStore()

  if (workStore && workUnitStore) {
    if (workUnitStore && !isRequestApiAllowedInCurrentPhase(workUnitStore)) {
      throw new Error(
        `Route ${workStore.route} used \`io()\` inside \`after()\` while rendering. The \`io()\` function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`
      )
    }
    switch (workUnitStore.type) {
      case 'request':
        // For dev renders we instrument the promise so it will show up in
        // React Suspense Devtools and, if also doing `instant` validation,
        // ensure it resolves in the right stage for staged rendering
        // In production we just let it resolve immediately because we're doing
        // a dynamic SSR or resume render and have no need to delay anything
        // after this call
        if (process.env.NODE_ENV === 'development') {
          if (workUnitStore.asyncApiPromises) {
            return workUnitStore.asyncApiPromises.io
          }
          return makeDevtoolsIOAwarePromise(
            undefined,
            workUnitStore,

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Do not call io() inside an after() callback; perform I/O before scheduling after().
Defensive patterns

Strategy: validation

When it happens

Trigger: io() is called inside an after() callback.

Common situations: Using the io() API within unstable_after where it is disallowed.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/6eb3287c67e8c941. Report an issue: GitHub.