Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Mar 31, 2025

resolves #956

@changeset-bot
Copy link

changeset-bot bot commented Mar 31, 2025

🦋 Changeset detected

Latest commit: d053a68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/next-on-pages Patch
eslint-plugin-next-on-pages Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 31, 2025

🧪 Prereleases are available for testing 🧪

@cloudflare/next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/14177289899/npm-package-next-on-pages-960

@cloudflare/eslint-plugin-next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/14177289899/npm-package-eslint-plugin-next-on-pages-960

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review March 31, 2025 12:02
@dario-piotrowicz dario-piotrowicz requested a review from vicb March 31, 2025 12:03
e.message.includes('Disallowed operation called within global scope')
) {
// Next.js attempted to create an AbortController in the global scope
// let's return something that looks like an AbortController but with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this not cause other problems? What if that AbortController is actually needed to clean stuff up? Are we just pushing the issue down the road with this fix? Do we know what AbortControllers are being instantiated in the top level scope outside of a request?

Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this not cause other problems? What if that AbortController is actually needed to clean stuff up? Are we just pushing the issue down the road with this fix?

Yes, that's totally the case, I'm just kicking the can down the road, hoping that this won't cause issues, thinking that we can deal with potential issues caused by this simplified implementation if/when they arise

Given the state of the project and the fact that we're focusing our efforts on the opennext adapter instead I would try not to invest too much time in finding the perfect solution here, just something good enough to unblock people while opennext is still in beta.

I totally understand your concerns though 😕

Do we know what AbortControllers are being instantiated in the top level scope outside of a request?

I am pretty confident that this is due to the fact that (for perf benefits) we dynamically import route functions, in those there are setup steps that create the AbortControllers, these aren't really done outside of the request, but workerd does view them in such a way, this is a workerd limitation that I already in the past flagged to the team: https://github.com/dario-piotrowicz/workerd-dynamic-imports-io-repro

@vicb
Copy link
Collaborator

vicb commented Mar 31, 2025

@conico974 made a similar patch for NoW.

You can see from the PR he links in the description that the AbortController is used on the client side but somehow ends up in server code ("// TODO: Figure out why this module is included in server page bundles.").

That should not cause any issue.

FYI, I'll probably remove the patch from NoW because we do not run user code at top level any more.

@dario-piotrowicz dario-piotrowicz enabled auto-merge (squash) March 31, 2025 17:11
@dario-piotrowicz dario-piotrowicz merged commit 95951ac into main Mar 31, 2025
16 of 18 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/next-15.2-fix branch March 31, 2025 17:12
@gavan-x
Copy link

gavan-x commented Apr 1, 2025

@vicb @dario-piotrowicz @petebacondarwin Thanks for this ❤️🔥.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: cloudflare broken with Next ^5.2.0 [await fetch]

4 participants