opennextjs-cloudflare: [BUG] Build Fails Due to Missing Durable Object Classes in Worker Configuration

Describe the bug

When attempting to create an optimized production build, the process fails due to missing Durable Object classes in the worker configuration. The following warnings and errors are encountered:

workerd/server/server.c++:1951: warning: A DurableObjectNamespace in the config referenced the class "DurableObjectQueueHandler", but no such Durable Object class is exported from the worker. Please make sure the class name matches, it is exported, and the class extends 'DurableObject'. Attempts to call to this Durable Object class will fail at runtime, but historically this was not a startup-time error. Future versions of workerd may make this a startup-time error.

workerd/server/server.c++:1951: warning: A DurableObjectNamespace in the config referenced the class "DOShardedTagCache", but no such Durable Object class is exported from the worker. Please make sure the class name matches, it is exported, and the class extends 'DurableObject'. Attempts to call to this Durable Object class will fail at runtime, but historically this was not a startup-time error. Future versions of workerd may make this a startup-time error.

service core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER: Worker "core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER"'s binding "DurableObjectQueueHandler" refers to a service "core:user:worker", but no such service is defined.

unhandledRejection [MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.] {
  code: 'ERR_RUNTIME_FAILURE',
  cause: undefined
}

Error: Command failed: npm run build

Steps to reproduce

wrangler.json

{
  "$schema": "node_modules/wrangler/config-schema.json",
  "main": ".open-next/worker.js",
  "name": "my app",
  "compatibility_date": "2024-12-30",
  "compatibility_flags": ["nodejs_compat"],
  "minify": true,
  "assets": {
    "directory": ".open-next/assets",
    "binding": "ASSETS",
  },
  "placement": {
    "mode": "smart",
  },
  "observability": {
    "enabled": true,
  },
  "r2_buckets": [
    {
      "bucket_name": "dimlly-isr-tags",
      "binding": "dimlly_isr_tags",
    },
  ],

  "durable_objects": {
    "bindings": [
      {
        "name": "NEXT_CACHE_REVALIDATION_DURABLE_OBJECT",
        "class_name": "DurableObjectQueueHandler",
      },
      {
        "name": "NEXT_CACHE_DO_SHARDED",
        "class_name": "DOShardedTagCache",
      },
    ],
  },
  "migrations": [
    {
      "tag": "v1",
      "new_sqlite_classes": ["DurableObjectQueueHandler", "DOShardedTagCache"],
    },
  ],
}

open-next.config.ts

import { defineCloudflareConfig } from '@opennextjs/cloudflare';
import kvIncrementalCache from '@opennextjs/cloudflare/overrides/incremental-cache/kv-incremental-cache';
import memoryQueue from '@opennextjs/cloudflare/overrides/queue/do-queue';
import doShardedTagCache from '@opennextjs/cloudflare/overrides/tag-cache/do-sharded-tag-cache';

export default defineCloudflareConfig({
  incrementalCache: kvIncrementalCache,
  tagCache: doShardedTagCache({ baseShardSize: 12, regionalCache: true }),
  queue: memoryQueue,
});

Expected behavior

Fix

@opennextjs/cloudflare version

0.6.0

Wrangler version

4.5.0

next info output

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0;
Binaries:
  Node: 23.5.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 9.15.4
Relevant Packages:
  next: 15.2.4
  eslint-config-next: 15.2.4
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (3 by maintainers)

Most upvoted comments

@ibobo you shouldn’t need script_name when you use the most recent wrangler

I confirm now script_name is not needed anymore. Thanks.

@zoroblox You tried setting it to "app_name" right ? And what versions of @opennextjs/cloudflare are you using ?

@conico974 My bad, i’m so sorry. I updated @opennextjs/cloudflare and wrangler to the latest version and now the error is gone. Thank you so much

The DO part of the issue will be fixed with https://github.com/cloudflare/workers-sdk/pull/8697 that should land in wrangler next week.

Meanwhile you can add a script_name to your working binding and set that to your worker name as a workaround.

sure here you go muhamad-rizki/cfnextjs-repro it happens only on deploy command due to executing D1 populateCache

Creating D1 table if necessary...
✘ [ERROR] Error: must provide --command or --file.

Thanks, yeah, this looks like a difference between how yarn classic and yarn modern work. I was testing with yarn classic earlier, but I can reproduce with yarn modern.

Have raised #512 to fix.

@james-elicx any idea ?