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

fix: provide a proper error message when using getCloudflareContext in static routes #330

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

dario-piotrowicz
Copy link
Contributor

getCloudflareContext can't be used in static routes, currently a misleading error
message incorrectly tells the developer that they haven't called initOpenNextCloudflareForDev
in their config file, this change updates such error message to properly clarify what
the issue is (and how to solve it)


fixes #317

Copy link

changeset-bot bot commented Feb 3, 2025

🦋 Changeset detected

Latest commit: c93380e

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

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare 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

@dario-piotrowicz dario-piotrowicz requested a review from vicb February 3, 2025 11:48
Copy link

pkg-pr-new bot commented Feb 3, 2025

Open in Stackblitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@330

commit: c93380e

Copy link
Contributor

@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.

Would there be a way to test this? (i.e. launch next build and check the errors`)

@dario-piotrowicz
Copy link
Contributor Author

Would there be a way to test this? (i.e. launch next build and check the errors`)

I was thinking the same too, I don't think this could be tested using our e2es/playwright, so testing this would require a new type of test, a sort of semi-e2e one in which we run the build command and test the result, that's totally doable I think, but not trivial (but also probably not super complex) which would also increase maintenance costs. I am not sure if it's worth it (especially for just testing these error messages), but if you think it is I'm happy to work on it (potentially in a followup PR as there are other things that we could test in such a way, like the messages we present to the users during build)

just let me know can I can work on it 👍

@vicb
Copy link
Contributor

vicb commented Feb 3, 2025

Would there be a way to test this? (i.e. launch next build and check the errors`)

I was thinking the same too, I don't think this could be tested using our e2es/playwright, so testing this would require a new type of test, a sort of semi-e2e one in which we run the build command and test the result, that's totally doable I think, but not trivial (but also probably not super complex) which would also increase maintenance costs. I am not sure if it's worth it (especially for just testing these error messages), but if you think it is I'm happy to work on it (potentially in a followup PR as there are other things that we could test in such a way, like the messages we present to the users during build)

just let me know can I can work on it 👍

Thanks, a follow up PR sounds great, can you create an issue?

@dario-piotrowicz
Copy link
Contributor Author

Thanks, a follow up PR sounds great, can you create an issue?

#331 🙂👍

(PS: again I'm not sure how we want to prioritize this, if you want me to work on it, I'm happy to work on it whenever)

@vicb vicb merged commit 6103547 into main Feb 3, 2025
7 checks passed
@vicb vicb deleted the dario/317/getCloudflareContext-ssg-error branch February 3, 2025 14:27
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] Build fails with getCloudflareContext() error
2 participants