cloudflare / cloudflare/workerd
🐛 BUG: Class instances cannot be used to create Workers
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
### Which Cloudflare product(s) does this pertain to?
Workers/Other
### What version of `Wrangler` are you using?
2.15.0
### What operating system are you using?
Linux
### Describe the Bug
Hey there! While developing an internal API framework for our Workers, I ran into an issue publishing a Worker using a class instance. Right now, Cloudflare's API refuses to accept that we're exporting a fetch function even though this code works in both Miniflare and wrangler dev:
```js
class Test {
async fetch(req, env, ctx) {
return new Response("Hello World")
}
}
const test = new Test()
export default test
```
Yields:
✘ [ERROR] A request to the Cloudflare API (/accounts//workers/scripts/mre) failed.
`The uploaded script has no registered event handlers. [code: 10068]`
Contributor guide
Assessment
This issue has not been assessed yet.