Repository navigation
[APPS-2945] Update: switch the apps plugin's static checks to the Node backend runtime - #557
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Runtime selection is consistently propagated, fails safely to v1, and has comprehensive coverage across affected execution paths.
Review effort: Balanced
Findings: None
What changed in this PR
Aligns backend static checks with each organization’s Terrapin feature-flag runtime while preserving v1 checks for cloud execution and fallback scenarios.
Changes:
- Adds memoized, authenticated backend-runtime resolution with safe v1 fallback.
- Threads runtime selection through build, transform, and local module-graph checks.
- Adds runtime-specific tests and documentation.
| File | Description |
|---|---|
packages/plugins/apps/src/backend-runtime.ts |
Resolves and caches the organization’s backend runtime. |
packages/plugins/apps/src/backend-runtime.test.ts |
Tests authentication, fallback, timeout, caching, and logging. |
packages/plugins/apps/src/backend/ast-parsing/run-backend-static-checks.ts |
Makes existing restrictions v1-only. |
packages/plugins/apps/src/backend/ast-parsing/run-backend-static-checks.test.ts |
Verifies runtime-specific checks and warnings. |
packages/plugins/apps/src/backend/ast-parsing/reject-restricted-globals.ts |
Updates runtime documentation. |
packages/plugins/apps/src/vite/index.ts |
Resolves and propagates runtime across Vite workflows. |
packages/plugins/apps/src/vite/index.test.ts |
Tests transforms, packaging, local execution, and dev:verify behavior. |
packages/plugins/apps/src/vite/backend-static-checks-plugin.ts |
Applies the selected runtime during nested builds. |
packages/plugins/apps/src/vite/backend-static-checks-plugin.test.ts |
Covers v1 and v2 plugin behavior. |
packages/plugins/apps/src/vite/build-backend-functions.ts |
Propagates runtime into production backend builds. |
packages/plugins/apps/src/vite/build-backend-functions.test.ts |
Tests runtime behavior in bundled dependency graphs. |
packages/plugins/apps/src/vite/dev-server-module-graph.ts |
Applies runtime-specific checks during local traversal. |
packages/plugins/apps/src/vite/dev-server-module-graph.test.ts |
Tests transitive module checks for both runtimes. |
packages/plugins/apps/src/vite/dev-server.ts |
Keeps cloud-generated bundles on v1. |
packages/plugins/apps/src/vite/dev-server.integration.test.ts |
Updates integration calls with explicit runtime. |
packages/plugins/apps/README.md |
Documents runtime resolution and resulting behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23556ed62a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6164a77 to
a160fb7
Compare
🎉 All green!🧪 All tests passed 🔗 Commit SHA: b71e121 | Docs | View more details | Give us feedback! |
14c5415 to
e898bea
Compare
abf34ad to
892bda9
Compare
2352fe9 to
e7d5434
Compare
e44fe4a to
141d960
Compare
04671dd to
696d422
Compare
a64a6ad to
31ea49f
Compare
e59b683 to
c499254
Compare
Live Debugger Runtime BenchmarkSDK-loaded dormant-probe runtime overhead, measured against an uninstrumented bundle in the same browser session.
What do the Tiny and Hot workloads represent? Browser Debugger SDK: Full diagnosticsRaw samples are in the |
c499254 to
06018e9
Compare
cf49bfa to
314d9ca
Compare
06018e9 to
7509268
Compare
314d9ca to
86c8430
Compare
eb7a6fb to
92afaf2
Compare
86c8430 to
b50260f
Compare
…d runtime Backend functions run on the Node backend runtime, but the plugin's static checks still enforced the Deno runtime's rules, so they rejected code the Node backend runtime runs. The checks now apply the Node backend runtime's rules: Node built-in imports and Node's network globals, such as fetch and WebSocket, are allowed, and XMLHttpRequest, EventSource and Deno, which Node lacks, are rejected with a hint. They fail only where the missing global would throw: a bare use other than typeof, or using it as an object, function or class, including through a binding it was declared or destructured into. Feature checks, polyfill installs, delete and destructuring defaults pass. The Deno-only checks are removed: the Node built-in import check, the network-global check and the crypto/Intl warning. Local execution runs on the developer's own Node, so the dev server now warns once at start when its major version isn't the Node backend runtime's (24), and when it's before 22, which lacks the global WebSocket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92afaf2 to
b71e121
Compare
Motivation
fetchand Node built-in imports. (APPS-2945, design)Architecture
flowchart TD T[".backend.* transform"] --> R["runBackendStaticChecks"] G["dev-server module-graph walk"] --> R B["production backend build (moduleParsed)"] --> R R --> M["rejectGlobalsMissingFromNode"] M --> Q{"XMLHttpRequest, EventSource or Deno used where undefined throws?"} Q -->|"bare use, or dereferenced, called, constructed, extended, destructured"| E["build error with a hint"] Q -->|"typeof, if, ??, delete, case, polyfill install, destructuring default"| A["allowed"]Changes
8 changes across the static checks, vite/index.ts, constants.ts, README.md and tests
XMLHttpRequest,EventSourceandDenowith hints.reject-globals-missing-from-node.tsrun-backend-static-checks.tsambient-global-access.tswalk-ast.tsvite/index.tsNODE_BACKEND_RUNTIMEand its Node major.constants.tsREADME.mdreject-globals-missing-from-node.test.ts,index.test.tsQA Instructions
b71e121fhttps://github.com/DataDog/build-plugins/actions/runs/39985850091DD_SITE=<staging site>,DD_API_KEYandDD_APP_KEY.QA helper scripts (also used by the stacked PRs)
install-plugin.sh:qa-run.sh:log-requests.mjs:Local execution and dev:verify: fetch, node:os, feature checks and defaults pass; Deno uses fail
src/useFetch.backend.ts:src/useNode.backend.ts:src/useDeno.backend.ts:src/useFeatureCheck.backend.ts:src/useDefaults.backend.ts:src/useDenoChain.backend.ts:Blast Radius
fetchpass, and the three missing globals fail where they'd throw.Out of Scope / Follow-ups
5 items deferred
letaliases ofglobalThis, bulk copiesdev:verifycatches themif (globalThis.Deno) globalThis.Deno.cwd()) still failschild_processimports passprocess.envvaluesjsSandboxWithActionsandbackendEnvironment: 'sandbox'paths are goneDocumentation
🤖 Generated with Claude Code