Skip to content

Dev server crashes on Workers: console.createTask exists but throws; React dev builds call it in every environment #3234

Description

@JamesbbBriz

Context

Running an App Router app in dev on the Cloudflare runtime (vinext dev with the workerd runner).

Observed

Every route 500s. Two distinct crashes, both rooted in console.createTask:

  1. The RSC environment dies at module initialization — React's dev build calls console.createTask(...) at module init (scheduler task tracing)
  2. The SSR child environment dies again during HTML rendering for the same reason

workerd's console exposes createTask but throws "not implemented" when it is actually called, so React's feature detection happily picks it up and then crashes on first use. A stub imported before the vinext handler fixes the RSC environment, but the SSR environment needs the polyfill too — the fix has to reach every vite environment.

Expected

Dev rendering should work on Workers out of the box; the runtime gap should be shimmed once, upstream, for all server environments.

Workaround (app-side)

// imported before vinext/server/fetch-handler
(console as any).createTask ??= (name: string) => ({ name, run: (fn: any) => fn() });

Fixed by #3233.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions