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

implement route scoping solution #836

Merged
merged 25 commits into from
Aug 2, 2024
Merged

implement route scoping solution #836

merged 25 commits into from
Aug 2, 2024

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Jul 23, 2024

currently routes all share the same global scope, this can be problematic and cause race conditions and failures, like the one presented in #805 that happens when various requests are handled in parallel (and the global scope ends up in an invalid state).

So, this PR solves the issue by wrapping each js file (functions and chunks included) in functions that override the self, globalThis and global symbols with proxies that try to make (as reasonably well as possible) each route's global scope as isolated as possible.


fixes #805

Copy link

changeset-bot bot commented Jul 23, 2024

🦋 Changeset detected

Latest commit: ca1ab06

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

Copy link
Contributor

github-actions bot commented Jul 23, 2024

🧪 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/10214693462/npm-package-next-on-pages-836

@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/10214693462/npm-package-eslint-plugin-next-on-pages-836

@dario-piotrowicz dario-piotrowicz changed the title implement scoping solution implement route scoping solution Jul 24, 2024
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review July 24, 2024 13:39
@dario-piotrowicz dario-piotrowicz marked this pull request as draft July 24, 2024 13:56
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review July 24, 2024 15:15
@dario-piotrowicz dario-piotrowicz force-pushed the useContext-fix branch 2 times, most recently from b122cc1 to 60158e1 Compare July 29, 2024 13:07
@dario-piotrowicz dario-piotrowicz marked this pull request as draft July 29, 2024 17:40
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review July 30, 2024 17:12
Copy link
Collaborator

@vicb vicb left a comment

Choose a reason for hiding this comment

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

I have done a first pass of review with my very limited knowedlge.

I'll do a second pass of review tomorrow.

One thing that would be nice is a high level description of what the PR do - 1 or 2 sentences to give context, describes the problem that is solved (the content is currently empty).

use a single return statement instead of updating fileContents
avoid unnecessary spreading
@dario-piotrowicz dario-piotrowicz marked this pull request as draft August 1, 2024 16:25
introduce namedExportsObjectName to make solution less ugly/brittle
fix wrong namedExportsObjectName name
update namedExportsObjectName name (for consistency)
improve named exports solution a bit further
make sure solution works with older versions of the Vercel CLI
use more consistent param names
join using newlines instead of semicolons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: React contexts break when loading pages in parallel
3 participants