-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(core): When an error occurs during SSR due to using the browser APIs, show an explanation #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
Open
JerryWu1234
wants to merge
20
commits into
QwikDev:build/v2
Choose a base branch
from
JerryWu1234:v2-7514-improvement-usetask
base: build/v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(core): When an error occurs during SSR due to using the browser APIs, show an explanation #7571
JerryWu1234
wants to merge
20
commits into
QwikDev:build/v2
from
JerryWu1234:v2-7514-improvement-usetask
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 764d3b2 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.
wmertens
requested changes
May 11, 2025
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
|
Ensure the test correctly verifies error messages thrown within useTask$ by adding a new component and refining assertions
Modify the test to wrap components with ErrorProvider and update the expected error message. This ensures consistent error handling and improves test reliability.
…yWu1234/qwik into v2-7514-improvement-usetask
…uard in useTask$ The new rule `scope-use-task` ensures that Node.js APIs (e.g., `process.env`) are only used within `useTask$` when guarded by a server check (e.g., `isServer`). This prevents unsafe usage of Node.js APIs in client-side code. The rule also checks for indirect API usage via function calls and provides appropriate error messages to guide developers in adding the necessary guards.
Refactor test files to include additional scenarios for unsafe API usage in Qwik components. This ensures comprehensive coverage for detecting unsafe API calls in various contexts.
…yWu1234/qwik into v2-7514-improvement-usetask
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is it?
Description
I add if (isDev) {if (isServer) {...} else {...}} and in there I check if the error mentions window or document for the server
usage of Node.js's process object must be inside an if (isServer) statement.
We could throw a TypeScript error when a user uses process without wrapping it in an if (isServer) statement.
How do you think so
Checklist
pnpm change