Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: service core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER: Worker refers to a service "core:user:worker", but no such service is defined. #7670

Closed
flashblaze opened this issue Jan 5, 2025 · 6 comments
Labels
bug Something that isn't working Workers + Assets

Comments

@flashblaze
Copy link
Contributor

Which Cloudflare product(s) does this pertain to?

Miniflare

What versions are you using?

3.99.0 [wrangler], 4.20241230.0, [@cloudflare/workers-types]

What operating system and version are you using?

WSL Ubuntu

Please provide a link to a minimal reproduction

No response

Describe the Bug

I'm using Nuxt with Workers Static Assets. When I deploy my app, Durable Objects work. However, it does not work in dev server.

wrangler.toml

#:schema node_modules/wrangler/config-schema.json
name = "dummy-worker"
main = "./worker-entry.mjs"
compatibility_date = "2025-01-04"
compatibility_flags = ["nodejs_compat"]
assets = { directory = "./.output/public/", binding = "ASSETS" }

[observability]
enabled = true

[vars]
NODE_VERSION = "20.17.0"
PNPM_VERSION = "9.12.3"

[[durable_objects.bindings]]
name = "DUMMY_OBJECT"
class_name = "DummyDurableObject"

[[migrations]]
tag = "v1"
new_classes = ["MyDurableObject"]

[[migrations]]
tag = "v2"
renamed_classes = [
    { from = "MyDurableObject", to = "DummyDurableObject" },
]

worker-entry.mjs

// worker-entry.mjs
export { default } from './.output/server/index.mjs';
export { DummyDurableObject} from './functions/durable.ts';

worker-configuration.d.ts

// Generated by Wrangler by running `wrangler types`

interface Env {
	NODE_VERSION: "20.17.0";
	PNPM_VERSION: "9.12.3";
	DUMMY_OBJECT: DurableObjectNamespace<import("./worker-entry").DummyDurableObject>;
	ASSETS: Fetcher;
}

package,json

{
  "name": "dummy-worker",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "pnpm run build && wrangler dev",
    "postinstall": "nuxt prepare",
    "lint": "eslint .",
    "lint:fix": "eslint . --fix",
    "deploy": "pnpm run build && wrangler deploy",
    "cf-typegen": "wrangler types"
  },
  "dependencies": {
    "@nuxt/eslint": "^0.7.2",
    "@primevue/themes": "^4.2.5",
    "nuxt": "^3.15.0",
    "primevue": "^3.53.1",
    "shiki": "^1.26.1",
    "tailwindcss-primeui": "^0.3.4",
    "vue": "latest",
    "vue-router": "latest"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20241230.0",
    "@nuxt/eslint-config": "^0.7.4",
    "@nuxtjs/tailwindcss": "^6.12.2",
    "autoprefixer": "^10.4.20",
    "eslint": "^9.17.0",
    "h3": "^1.13.0",
    "nitro-cloudflare-dev": "^0.2.1",
    "nuxt-primevue": "3",
    "postcss": "^8.4.49",
    "tailwindcss": "^3.4.17",
    "typescript": "^5.7.2",
    "wrangler": "^3.99.0"
  }
}

nuxt.config.ts

import { defineNuxtConfig } from 'nuxt/config';

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  runtimeConfig: {
    environment: process.env.NODE_ENV || 'development'
  },
  modules: ['nuxt-primevue', '@nuxt/eslint', 'nitro-cloudflare-dev'],
  devtools: { enabled: true },
  css: ['~/assets/css/main.css', 'primevue/resources/themes/aura-light-green/theme.css'],
  compatibilityDate: '2025-01-04',
  nitro: {
    preset: 'cloudflare_module',
    experimental: {
      websocket: true,
    },
  },
  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {},
    },
  },
  eslint: {
    config: {
      autoInit: true,
      stylistic: {
        quotes: 'single',
        semi: true,
      },
    },
  },
  primevue: {
    components: {
      include: ['Button'],
    },
  },
});

Please provide any relevant error logs

When i run pnpm dev, this is the log output

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


 ERROR  Failed to initialize wrangler bindings proxy The Workers runtime failed to start. There is likely additional logging output above.

    at Miniflare2.#assembleAndUpdateConfig (node_modules/.pnpm/[email protected]/node_modules/miniflare/src/index.ts:1404:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Mutex.runWith (node_modules/.pnpm/[email protected]/node_modules/miniflare/src/workers/shared/sync.ts:66:45)
    at async Miniflare2.#waitForReady (node_modules/.pnpm/[email protected]/node_modules/miniflare/src/index.ts:1486:3)
    at async Miniflare2._getProxyClient (node_modules/.pnpm/[email protected]/node_modules/miniflare/src/index.ts:1692:3)
    at async Miniflare2.getBindings (node_modules/.pnpm/[email protected]/node_modules/miniflare/src/index.ts:1715:23)
    at async getPlatformProxy (node_modules/.pnpm/[email protected]_@[email protected]/node_modules/wrangler/wrangler-dist/cli.js:180408:20)
    at async _getPlatformProxy (node_modules/.pnpm/[email protected]/node_modules/nitro-cloudflare-dev/dist/runtime/plugin.dev.mjs:48:17)
@flashblaze flashblaze added the bug Something that isn't working label Jan 5, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 5, 2025
@flashblaze flashblaze changed the title 🐛 BUG: 🐛 BUG: service core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER: Worker "core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER"'s binding "DummyDurableObject" refers to a service "core:user:worker", but no such service is defined. Jan 5, 2025
@flashblaze flashblaze changed the title 🐛 BUG: service core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER: Worker "core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER"'s binding "DummyDurableObject" refers to a service "core:user:worker", but no such service is defined. 🐛 BUG: service core:user:__WRANGLER_EXTERNAL_DURABLE_OBJECTS_WORKER: Worker refers to a service "core:user:worker", but no such service is defined. Jan 5, 2025
@emily-shen
Copy link
Contributor

cc @edmundhung is working on it in #7292 🧡

@edmundhung was there any workaround in the meantime?

@emily-shen emily-shen moved this from Untriaged to Backlog in workers-sdk Jan 6, 2025
@edmundhung
Copy link
Member

Hi @flashblaze,

Sorry about the unhelpful error message! The Nuxt integration relies on the getPlatformProxy API, which currently doesn’t support Durable Objects on your main worker.

As a workaround, you can run your Durable Object on a separate worker and specify a script_name in the configuration. For more details, please refer to the docs: https://developers.cloudflare.com/workers/wrangler/api/#supported-bindings

@flashblaze
Copy link
Contributor Author

Thanks for the help @emily-shen and @edmundhung! I'll keep the issue open for now and close this once I've got it up and running by today or tomorrow. I hope that's fine.

@flashblaze
Copy link
Contributor Author

@edmundhung

I have this api route which would be turned into a worker call. I verified this since it is working after deployment.

// server/api/durable-object.ts
export default defineEventHandler(async (event) => {
    try {
        const env = event.context.cloudflare?.env || event.context.env;
        if (!env?.DUMMY_OBJECT) {
            return { error: 'DUMMY_OBJECT binding not found!' };
        }

        const id = env.DUMMY_OBJECT.idFromName('counter');
        const stub = env.DUMMY_OBJECT.get(id);

        const response = await stub.fetch(event.context.cloudflare.request);
        const data = await response.json() as { value: number };
        return data;
    }
    catch (error) {
        console.error(error);
        return { error: 'Failed to fetch from Durable Object' };
    }
});

I'm calling this route like so from my client

<script setup lang="ts">
const message = ref<number | null>(null);
const error = ref<string | null>(null);

type DurableObjectResponse = {
  value: number;
} | {
  error: string;
};

const callDurableObject = async () => {
  try {
    const response = await $fetch<DurableObjectResponse>('/api/durable-object');
    if ('value' in response) {
      message.value = response.value;
      error.value = null;
    }
    else {
      error.value = response.error;
      message.value = null;
    }
  }
  catch (error) {
    console.error(error);
  }
};
</script>

<template>
  <div class="space-y-4">
    <div>
      <Button @click="callDurableObject">
        Call Durable Object
      </Button>
      <p v-if="message !== null" class="mt-2">
        Response: {{ message }}
      </p>
      <p v-if="error" class="mt-2 text-red-500">
        Error: {{ error }}
      </p>
    </div>
  </div>
</template>

If possible, could you guide me on how can I create a custom script in which I can call my DO with the same functionality as durable-object.ts?

@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Jan 11, 2025
@paulius1230
Copy link

@flashblaze Did you solve this issue?

@flashblaze
Copy link
Contributor Author

Unfortunately no @paulius1230
I moved to separate Hono backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working Workers + Assets
Projects
None yet
Development

No branches or pull requests

4 participants