[APPS-2792] Add: harden the in-process local execution path - #480
Draft
tyffical wants to merge 2 commits into
Draft
Conversation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 8292a6a | Docs | Datadog PR Page | Give us feedback! |
tyffical
force-pushed
the
tiffany.trinh/apps-2792-harden-local-execution-v2
branch
from
August 7, 2026 15:17
6e85225 to
64c7a61
Compare
Serializes local backend-function executions via a promise-chain queue, since @datadog/action-catalog and @datadog/apps-backend both register runtime context via a shared, module-level setter that isn't safe under concurrent in-process execution. Also populates $.Source with a synthetic local-dev identity (deferred from Milestone 0), and adds edge-case coverage: non-serializable results, a top-level module throw, and a real concurrent-execution test against a genuine @datadog/apps-backend typed import confirming no cross-execution state leakage.
tyffical
force-pushed
the
tiffany.trinh/apps-2792-harden-local-execution-v2
branch
from
August 7, 2026 19:55
64c7a61 to
41a772e
Compare
This was referenced Aug 7, 2026
Runs the readOwnArgsAfterDelay concurrency check through the real, serialized executeScriptLocally entrypoint (its test.skip counterpart against PR #479's un-serialized base fails with cross-contaminated args). Passing here confirms the enqueue/queueTail promise-chain mutex actually closes the globalThis.$ race, not just reorders interleaved work.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
@datadog/action-catalog'ssetExecuteActionImplementationand@datadog/apps-backend'ssetBackendboth register runtime context via a shared, module-level setter. Without serialization, a second concurrent execution's registration could silently redirect the first's still-in-flight typed-import calls to the wrong identity — with no error at all. See the RFC's Decisions and Trade-Offs.Changes
enqueue) — never run concurrently. A rejected execution doesn't wedge the queue for whatever's next.BigIntgets a clear, attributed error instead of an opaque downstreamJSON.stringifyfailure; a bare function/Symbol(whichJSON.stringifysilently drops instead of throwing) is also caught explicitly.globalThisorder marker, not a mock); the queue keeps flowing after an earlier execution rejects; aloadModulerejection (simulating a native-module load failure) rejects cleanly; all three non-serializable-result shapes; the no-token-exposure and$.Sourceinvariants from #479 are re-verified against the queued path.QA Instructions
yarn test:unit packages/plugins/apps/src/vite/local-execution.test.ts # Expected: Test Suites: 1 passed / Tests: 20 passed ✅ VERIFIEDyarn test:unit packages/plugins/apps # Expected: Test Suites: 23 passed / Tests: 305 passed ✅ VERIFIEDyarn workspace @dd/apps-plugin run typecheck # Expected: no output, clean exit ✅ VERIFIEDnpx eslint packages/plugins/apps/src/vite/local-execution.ts packages/plugins/apps/src/vite/local-execution.test.ts --quiet # Expected: no output, clean exit ✅ VERIFIEDNo manual local/staging QA for this PR specifically, same reasoning as #479: this module still isn't wired into
createDevServerMiddleware(that's Milestone 2, stacked next as #481), so there's nonpm run devrequest path that reaches it yet.Blast Radius
local-execution.tsstill isn't called from anywhere in the existing dev server.Out of Scope / Follow-ups
handleExecuteAction, threading a realLoadModule,/__dd/executeActionViaCloudsplit, realpreview-asynccalls)$.Actionsexecutionnet.Socket.prototype.connect,fetch, andchild_process'sspawn/exec/execSyncfor the duration of a local execution, exempted only around the internal$.Actions→executeActioncallDocumentation