Skip to content

feat(react-router): Auto-inject server instrumentation via top-level import#22441

Draft
chargome wants to merge 2 commits into
developfrom
feat/react-router-auto-inject-server-top-level
Draft

feat(react-router): Auto-inject server instrumentation via top-level import#22441
chargome wants to merge 2 commits into
developfrom
feat/react-router-auto-inject-server-top-level

Conversation

@chargome

Copy link
Copy Markdown
Member

Adds an opt-in autoInjectServerInstrumentation build option that prepends a top-level import of the server instrumentation file (default ./instrument.server.mjs) to the built server entry, so users no longer need NODE_OPTIONS='--import ...' in their start script. A top-level import is sufficient because deep library instrumentation is handled by the orchestrion instrumentation. Defaults to false for now; will default
to true in once orchestrion is the default.

closes #22413

@chargome chargome self-assigned this Jul 21, 2026
…njection

CodeQL (js/file-system-race) flagged the check-then-use pattern in the auto-inject
build hook: `existsSync` was followed later by `readFileSync`/`copyFileSync` on the same
paths, leaving a TOCTOU gap where the file could change between check and use.

Attempt the read and copy directly inside try/catch instead, removing the prior existence
checks. User-facing warnings and skip behavior are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-inject server instrumentation (top-level import)

2 participants