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: Uncaught TypeError: Class extends value undefined is not a constructor or null #3738

Closed
Skye-31 opened this issue Aug 11, 2023 · 3 comments · Fixed by #4337
Closed
Labels
bug Something that isn't working

Comments

@Skye-31
Copy link
Contributor

Skye-31 commented Aug 11, 2023

Which Cloudflare product(s) does this pertain to?

Wrangler core, Other

What version(s) of the tool(s) are you using?

Wrangler 3.5.0

What version of Node are you using?

18.17.0

What operating system are you using?

Mac

Describe the Bug

When creating a worker that defines a Durable Object (but doesn't export it in the main file), a very cryptic error is thrown

service core:user:my-worker: Uncaught TypeError: Class extends value undefined is not a constructor or null
  at index.js:1648:44 in maskDurableObjectDefinition
  at index.js:1657:26
✘ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

We should probably check whether the main script exports the DO, and if it doesn't, provide an easier to understand error.

Please provide a link to a minimal reproduction

export default {}
// note, the lack of `export class MyDO`
name = "my-worker"
script = "src/index.ts"
compatibility_date = "2023-08-11"

[[durable_objects.bindings]]
name = "MY_DO"
class_name = "MyDO"

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

Please provide any relevant error logs

No response

@Skye-31 Skye-31 added the bug Something that isn't working label Aug 11, 2023
@Meai
Copy link

Meai commented Nov 2, 2023

@Skye-31 I am also getting this error in a nextjs project after doing a next-on-pages build but I am already exporting the class

@Skye-31
Copy link
Contributor Author

Skye-31 commented Nov 3, 2023

I am also getting this error in a nextjs project after doing a next-on-pages build but I am already exporting the class

@Meai that sounds like a different issue - this is purely for improving the messaging when you're not exporting the DO. As a side note, I don't believe pages supports Durable Objects within Functions - you'd have to bind to a separate worker

@gerhardcit
Copy link
Contributor

I am also getting this error in a nextjs project after doing a next-on-pages build but I am already exporting the class

@Meai that sounds like a different issue - this is purely for improving the messaging when you're not exporting the DO. As a side note, I don't believe pages supports Durable Objects within Functions - you'd have to bind to a separate worker

Have this changed recently @Skye-31 . I think pages do support Durable Objects now. It would be great to see a good example of how to export a DO class correctly?

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants