cloudflare / cloudflare/workerd
`AbortController` outside of request context
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
Creating an `AbortController` outside of the request context will throw an exception even if not used `Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler`
It could cause issue, especially while bundling other lib (for example https://github.com/opennextjs/opennextjs-cloudflare/pull/441). It can even fail silently, like in the linked PR, making it very hard to debug
Not sure if this is the expected behavior or not.
```js
const a = new AbortController()
addEventListener("fetch", event => {
event.respondWith(new Response("Hello World"));
});
```
Contributor guide
Assessment
This issue has not been assessed yet.