fix(nitro): scope runtime config probes to active major version#340
fix(nitro): scope runtime config probes to active major version#340HugoRCD wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for following the naming conventions! 🙏 |
📝 WalkthroughWalkthroughEvlog inlines module config into Nitro bundles via EVLOG_CONFIG and adds setActiveNitroRuntime so the shared bridge reads inlined config first and probes only the declared Nitro major runtime (v2 or v3), avoiding cross-version dynamic imports at runtime. ChangesNitro Runtime Version Activation for Config Probing
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Benchmark reportBundle size
|
commit: |
|
@gtothesquare Can you try running |
@HugoRCD sorry for the late reply I was a week off without my computer. Still an issue, i (codex :) ) have created a minimal repo so you can reproduce https://github.com/gtothesquare/evlog-340-repo maybe there is something i did wrong in the setup. Seems like it still has to do a runtime dynamic import to get config |
The Nitro plugin's runtime probe of `nitro/runtime-config` transitively imports `#nitro/virtual/runtime-config`, a build-only virtual module that does not exist in deployed bundles. On Vercel + Bun the missing virtual triggered Bun's package auto-installer and crashed every request with `ReadOnlyFileSystem`. The previous `setActiveNitroRuntime` fix only narrowed which runtime to probe — the v3 probe itself still ran and still crashed. Bake the evlog config into the bundle as a literal via `nitro.options.replace.__EVLOG_CONFIG__`. The shared bridge reads that literal first and short-circuits all runtime probing — both for the plugin (`resolveEvlogConfigForNitroPlugin`) and for adapters resolving through `useRuntimeConfig().evlog.<ns>` (`getNitroRuntimeConfigRecord` returns a synthetic record). No dynamic import, no env propagation guesswork.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/nitro-bridge-active-runtime.md:
- Line 5: Add a top-level H1 heading immediately after the existing frontmatter
to satisfy markdownlint rule MD041; update the .changeset markdown so it
contains a single-line H1 (e.g., "# Nitro bridge active runtime") right after
the YAML frontmatter block to remove the lint warning.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c2bd96d5-a540-433a-b81d-1b28418a07d9
📒 Files selected for processing (5)
.changeset/nitro-bridge-active-runtime.mdpackages/evlog/src/nitro-v3/module.tspackages/evlog/src/nitro/module.tspackages/evlog/src/shared/nitroConfigBridge.tspackages/evlog/test/shared/nitroConfigBridge.test.ts
Could you try again? |
🔗 Linked issue
Closes #312
📚 Description
On Vercel + Bun + Nitro v3, every request crashed with
bun is unable to write files: ReadOnlyFileSystem. Root cause: the shared config bridge probednitropack/runtime/internal/configeven though onlynitro(v3) was installed. Bun's auto-install kicked in on the missing dynamic import and tried to writenode_modules/.cache, which is read-only on Vercel functions.The fix introduces an internal
setActiveNitroRuntime('v2' | 'v3')declaration. Both Nitro plugins call it as their first synchronous statement, and the bridge probes only the matching runtime —nitro/runtime-configfor v3,nitropack/...for v2. Adapters resolving config throughruntimeConfig.evlog.<adapter>benefit from the same restriction, socreatePostHogDrain()(and anyresolveAdapterConfigconsumer) no longer triggers cross-version probes.process.env.__EVLOG_CONFIGremains the highest-priority lookup; the historical fallback chain still applies when no runtime has been declared (standalone use outside Nitro).No public-API change.
📝 Checklist
Summary by CodeRabbit
Bug Fixes
New Features
Tests