fix(ai): direct require('node:fs') in getProcEnv breaks browser bundlers#102955
fix(ai): direct require('node:fs') in getProcEnv breaks browser bundlers#102955aniruddhaadak80 wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 11:41 AM ET / 15:41 UTC. Summary PR surface: Source +2. Total +2 across 1 file. Reproducibility: Partially: current main still contains the exact static Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one narrow PR that removes the static Node builtin require literal via the existing helper after real bundler proof is added and the duplicate candidate branch is resolved. Do we have a high-confidence way to reproduce the issue? Partially: current main still contains the exact static Is this the best way to solve the issue? Yes, likely: using the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 20816f676f37. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +2. Total +2 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Closing as superseded by #102947, now landed on The canonical PR applies the same owner-boundary fix and adds a browser-bundle regression. Exact-head proof included all 350 Thank you @aniruddhaadak80 for identifying and proposing the fix for this browser-bundling gap. |
Description
In
packages/ai/src/env-api-keys.ts, the file carefully avoids top-level imports of Node.js modules to ensure browser and Vite builds do not fail.However, inside the
getProcEnvhelper, it performs a direct, un-guardedrequire("node:fs"):Impact
Vite and other static bundlers scan source code for occurrences of
require("node:fs"). Even if wrapped in atry...catchblock and guarded by runtime checks, this direct literal string import will trigger static dependency resolution warnings or compile/bundle failures in non-Node browser environments.Suggested Fix
Use the existing
loadNodeBuiltinModulewrapper function which handles dynamic require safely without exposing raw string literals to static bundlers: