Skip to content

wrangler dev --local cannot start the worker: index.ts exports non-handler constants #1324

Open

Description

@neuromechanist

bunx wrangler dev -c wrangler-sccn.toml --env dev --local fails before serving a single request:

✘ [ERROR] service core:user:nemar-api-dev: Uncaught TypeError: Incorrect type for map entry 'NON_PROD_SANDBOX_CLEANUP_QUERY': the provided value is not of type 'function or ExportedHandler'.
✘ [ERROR] The Workers runtime failed to start.

Reproduced on 2026-09-08 with wrangler 4.85.0 and 4.130.0, on the unmodified dev entry point. The deployed worker is unaffected because production only reads the default export, but the local runtime treats every named export of the entry module as a potential entrypoint and rejects a string.

Cause

backend/src/index.ts exports NON_PROD_SANDBOX_CLEANUP_QUERY, PROD_SANDBOX_CLEANUP_QUERY, and DEV_CRON_ALLOWLIST so that backend/test/cron-dev-safety.test.ts and backend/test/exemplar-wiring.test.ts can import the production SQL rather than retype it.

Fix

  • Move the three constants to a new module (for example backend/src/services/cron-safety.ts), import them into index.ts, and point the two tests at the new module.
  • Leave index.ts with only export default { fetch, scheduled }.
  • Add a pure test that reads backend/src/index.ts as text and asserts it has exactly one export statement, so the regression cannot come back silently (the same source-text pattern exemplar-wiring.test.ts already uses).

Found while writing the MCP phase 2 smoke script (#1294, PR #1323); that script sidesteps the problem with its own minimal entry module until this lands.

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