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
📖 Documentation (updates to the documentation or readme)
🐞 Bug fix (a non-breaking change that fixes an issue)
👌 Enhancement (improving an existing functionality like performance)
✨ New feature (a non-breaking change that adds functionality)
⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
The cause differs from upstream, but the same error occurs in bridge, so this PR fixes it.
On the client, globalThis.$fetch is set in a plugin (nitro-bridge.client.mjs), but Nuxt 2's .nuxt/index.js evaluates App.js (which statically imports layouts) and store.js (which requires store modules) before plugins.
As a result, using $fetch at the top level of a module reachable from a layout or store throws ReferenceError: $fetch is not defined on the client and breaks hydration.
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
📝 Walkthrough
Walkthrough
The bridge generates a typed fetch module and registers its $fetch export for auto-import. Runtime composables use that instance, while server-side request fetch remains preferred when available. The playground adds a custom fetch example and a browser test. Vitest maps the generated module to a test mock, and the playground entry pattern includes composables.
The change makes $fetch available to the top-level playground composable before it runs. No actionable merge-blocking risk remains after normal checks.
Pre-merge checks | 4 | 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 9 files. (2 skipped: 2 …
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name
Status
Explanation
Title check
The title clearly identifies the main change: making $fetch available through auto-imports where possible. It is concise and specific to the reported bug fix.
Description check
The description explains the client-side evaluation-order issue, the resulting ReferenceError, and the intended hydration fix. It is directly related to the changeset.
Linked Issues check
Issue #1867 requests auto-importing $fetch where possible and porting the related upstream behavior. The PR generates #build/fetch.mjs, registers $fetch in granularAppPresets, and uses the gen…
Out of Scope Changes check
The changes stay within issue #1867. The generated fetch module, auto-import preset, runtime import updates, client side-effect import, Vitest mock alias, playground fixture, workspace pattern, and hy…
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 9 files. (2 skipped: 2 unsupported.)
Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
Error: typescript-eslint does not support TS 7.0.
at Object. (/.eslint-tmp/node_modules/.pnpm/typescript-eslint@8.71.1_eslint@9.39.4_jiti@1.21.7_supports-color@7.2.0__supports-color@7.2.0_typescript@7.0.2/node_modules/typescript-eslint/dist/index.js:52:11)
at Module._compile (node:internal/modules/cjs/loader:1830:14)
at Object..js (node:internal/modules/cjs/loader:1961:10)
at Module.load (node:internal/modules/cjs/loader:1553:32)
at Module._load (node:internal/modules/cjs/loader:1355:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:326:3)
at ModuleWrap. (node:internal/modules/esm/translators:231:7)
at ModuleJob.run (node:internal/modules/esm/module_job:437:25)
at async node:internal/modules/esm/loader:639:26
packages/bridge/src/imports/presets.ts
ESLint skipped: the matched ESLint configuration already failed (config-incompatibility).
packages/bridge/src/runtime/composables/fetch.ts
ESLint skipped: the matched ESLint configuration already failed (config-incompatibility).
7 others
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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.
🔗 Linked issue
FIxes: #1867
❓ Type of change
📚 Description
The cause differs from upstream, but the same error occurs in bridge, so this PR fixes it.
On the client,
globalThis.$fetchis set in a plugin (nitro-bridge.client.mjs), but Nuxt 2's.nuxt/index.jsevaluatesApp.js(which statically imports layouts) andstore.js(whichrequires store modules) before plugins.As a result, using
$fetchat the top level of a module reachable from a layout or store throwsReferenceError: $fetch is not definedon the client and breaks hydration.📝 Checklist