Skip to content

Agents SDK crashes with error 1042 when routes config is present in wrangler.jsonc #1053

@bluk1020

Description

@bluk1020

Description

When using the Cloudflare Agents SDK with a routes configuration in wrangler.jsonc, the deployment fails with error 1042. Removing the routes block and configuring custom domains via the CF Dashboard or API works fine.

Steps to Reproduce

  1. Create a Worker using the Agents SDK with a Durable Object (e.g., extending AIChatAgent)
  2. Add a routes config to wrangler.jsonc:
{
  "name": "my-agent",
  "main": "src/index.ts",
  "routes": [
    { "pattern": "app.example.com/*", "zone_name": "example.com" }
  ],
  "durable_objects": {
    "bindings": [
      { "name": "MY_AGENT", "class_name": "MyAgent" }
    ]
  }
}
  1. Run wrangler deploy

Expected Behavior

Worker deploys with the configured route.

Actual Behavior

Deployment fails with error 1042.

Workaround

Remove routes from wrangler.jsonc and configure custom domains via the CF Dashboard or API instead. This works, but having to bypass wrangler.jsonc for routing defeats the purpose of declarative config.

Environment

  • wrangler v4.x
  • Agents SDK (latest)
  • Durable Objects with SQLite migrations
  • compatibility_date: 2025-03-04
  • compatibility_flags: ["nodejs_compat"]

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