[APPS-2792] Add: in-process local execution for backend functions - #479
Draft
tyffical wants to merge 1 commit into
Draft
[APPS-2792] Add: in-process local execution for backend functions#479tyffical wants to merge 1 commit into
tyffical wants to merge 1 commit into
Conversation
Executes a bundled backend function via a dynamic import() of a content-addressed data: URL, directly inside the Vite dev server's own process -- no forked child process. The dev server is already the isolation boundary from production, so a crash or hang here only affects the developer's own dev server; process-level isolation is deliberately not added preemptively. $.Actions calls resolve through a Proxy (ported from the render.ts $.Actions logic) that invokes a local, in-process function directly -- no IPC needed, since there's no separate process to cross. The remote call itself is still a stub pending the single-action execution endpoint. The $ context passed to the customer's module exposes only backendFunctionArgs and Actions -- verified by test -- so that once a real auth token is wired in for real action execution, it can live in a module-private closure the customer's dynamically-imported code has no way to reach.
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
child_process.fork()-based isolation entirely: the Vite dev server is already the isolation boundary from production, so a crash or hang in a customer's own local dev server is a contained, recoverable failure, not something that needs a separate forked child process.Changes
executeScriptLocally, which runs a bundled backend function via a dynamicimport()of a content-addresseddata:URL, directly inside this process — no forked child.$.ActionsProxy (nested-property-path walk →{fqn, inputs}) from the closed fork-based prototype as a direct in-process function call instead of an IPC round trip.$context passed to the customer's module exposes onlybackendFunctionArgsandActions— verified by test — so a real auth token can later live in a module-private closure the customer's code has no way to reach.$.Actionscall resolution and validation, sync/async error propagation, timeout behavior, and the no-token-exposure invariant.QA Instructions
yarn test:unit packages/plugins/apps/src/vite/local-execution.test.ts # Expected: Test Suites: 1 passed / Tests: 9 passed ✅ VERIFIEDyarn test:unit packages/plugins/apps # Expected: Test Suites: 23 passed / Tests: 294 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 or staging QA for this PR specifically: this module isn't wired into
createDevServerMiddlewareyet, so there's nonpm run devrequest path that reachesexecuteScriptLocally()— nothing a human can click through yet, matching the same situation the original fork-based prototype (#461) was in. The tests above exercise a real, unmocked dynamicimport()of real generated code end-to-end, not a mocked substitute. Real local + staging manual QA becomes possible once this is wired into the dev server (follow-up PR).Blast Radius
Out of Scope / Follow-ups
handleExecuteAction)$.ActionsexecutionexecuteActionRemotelystays a stub until thenDocumentation