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

Introduce no nodejs compat flag error page #479

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Oct 2, 2023

@WalshyDev has pointed out to me the fact that our runtime error message: Error: Could not access built-in Node.js modules. Please make sure that your Cloudflare Pages project has the 'nodejs_compat' compatibility flag set. is probably not clear and developers don't get enough instructions on what to do, so to improve things I've updated next-on-pages to serve a more descriptive and actionable error page in case of this runtime issue.

when we'll have configs for Pages projects I think this should become a build time error instead of a runtime one, but for now we can only deal with this at runtime 🥲

Result: https://cede2e83.next-nodejs-compat-page-test.pages.dev/

Screenshot 2023-10-04 at 22 51 13

because of the lack of better ideas I tried to mimic the error page developers get when a worker throws: https://f6e0ff92.next-nodejs-compat-page-test.pages.dev/

@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2023

🦋 Changeset detected

Latest commit: 4678b4e

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 Minor
eslint-plugin-next-on-pages Minor

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 Oct 2, 2023

🧪 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/6430876971/npm-package-next-on-pages-479

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

Copy link
Member

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

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

The page we're using here has quite a few errors on it. I'd personally in-line it in the project so it's versioned with the package, but at the very least, we need to review the content of the page.

@dario-piotrowicz
Copy link
Member Author

The page we're using here has quite a few errors on it. I'd personally in-line it in the project so it's versioned with the package, but at the very least, we need to review the content of the page.

yeah good point about including it in the output app itself, I didn't want to include the html in the project's assets but by chatting with @petebacondarwin I understood that the impact it has on the app assets limits is very negligible, so I'm including it there and not having an external deployed app for this.

Regarding the errors on the page, I did notice that once I swapped compat and nodejs 🤦 I've fixed that, thanks for pointing that out, besides I can't spot other problems there, could you let me know what other errors you saw there? 😓

@dario-piotrowicz dario-piotrowicz force-pushed the improve-no-nodejs-compat-flag branch from df7c6b8 to e945607 Compare October 4, 2023 16:02
@dario-piotrowicz dario-piotrowicz force-pushed the improve-no-nodejs-compat-flag branch from 91e21c4 to 30de577 Compare October 4, 2023 16:13
Copy link
Member

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

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

Just some spelling/grammar nits. Thanks for shipping the page with the package directly rather than linking out!

@dario-piotrowicz dario-piotrowicz merged commit 2423529 into cloudflare:main Oct 6, 2023
8 checks passed
@dario-piotrowicz dario-piotrowicz deleted the improve-no-nodejs-compat-flag branch October 6, 2023 12:01
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.

5 participants