You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): When an error occurs during SSR due to using the browser APIs, show an explanation (#7571)
* fix(repl): improve deepUpdate logic for array item matching
* fix it
* fix(core): prevent server-side usage of browser APIs
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.
* add change
* fix(qrl): improve error message for browser API usage in SSR
* docs(changeset): update changeset from major to patch
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.
* feat(core): improve error message for SSR browser API usage
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.
* test(use-task): update test case for error handling in useTask$
Ensure the test correctly verifies error messages thrown within useTask$ by adding a new component and refining assertions
* test(use-task): update error handling test to use ErrorProvider
Modify the test to wrap components with ErrorProvider and update the expected error message. This ensures consistent error handling and improves test reliability.
* feat(eslint-plugin-qwik): add scope-use-task rule to enforce server guard 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.
* test(scope-use-task): update test cases for unsafe API usage
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.
* fix(qrl): handle window reference errors in server mode
Add try-catch block to handle ReferenceError for 'window' in server mode during development. Improve error message to guide developers to use 'if (isBrowser)' checks when needed.
Remove duplicate error handling code that was previously in the invoke function since it's now handled at the qrl level.
* ❤️
0 commit comments