-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(core): prevent server-side usage of browser APIs #7571
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
base: build/v2
Are you sure you want to change the base?
fix(core): prevent server-side usage of browser APIs #7571
Conversation
Build/v2
Add error handling for browser API usage during server-side rendering. The changes include: - Adding a new error code `QError.notUsingBrowserAPiInserver` to handle cases where browser APIs are used on the server. - Updating the `use-task.spec.tsx` test to catch and verify the new error. - Modifying `qrl-class.ts` to throw the error when browser APIs are accessed during server-side rendering. This ensures that developers are aware of and avoid using browser-specific APIs in server-side contexts, preventing runtime errors.
🦋 Changeset detectedLatest commit: ff28ef1 The changes in this PR will be included in the next version bump. 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 |
Update the changeset to correctly reflect the version bump as a patch instead of a major version change. This ensures accurate versioning and release notes.
try { | ||
await render(<Cmp />, { debug }); | ||
} catch (e: unknown) { | ||
expect((e as Error).message.includes('Code(Q51)')).toBeTruthy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs updating? Also test with a different error, check that it does not add the message but still throws
When an error occurs during SSR due to using browser APIs, provide a clearer explanation to help developers understand the issue and how to fix it. This enhances debugging experience and reduces confusion.
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
What is it?
Description
Checklist
pnpm change