Skip to content

AbortController outside of request context #3657

Open
@conico974

Description

@conico974

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 opennextjs/opennextjs-cloudflare#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.

const a = new AbortController()
addEventListener("fetch", event => {
  event.respondWith(new Response("Hello World"));
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions