You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(apps): harden local execution — serialization, Source, edge cases
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.
`Local execution of "${func.name}" returned a value that can't be serialized to JSON: ${
211
+
errinstanceofError ? err.message : String(err)
212
+
}`,
213
+
);
214
+
}
215
+
if(serialized===undefined&&result!==undefined){
216
+
thrownewError(
217
+
`Local execution of "${func.name}" returned a ${typeofresult} value, which JSON.stringify silently drops instead of serializing — return a plain JSON-compatible value instead.`,
218
+
);
219
+
}
220
+
returnresult;
221
+
}
222
+
167
223
/**
168
224
* Execute a backend function in-process by importing its real file directly
169
225
* — no bundling, no generated wrapper module. `globalThis.$` and the
170
226
* action-catalog/apps-backend registrations above stand in for what the
171
227
* removed `main($)` wrapper used to do textually; everything else about the
172
228
* call is just invoking the customer's exported function with its own real
173
229
* arguments.
230
+
*
231
+
* Serialized via `enqueue` — see its own doc comment for why.
174
232
*/
175
233
exportasyncfunctionexecuteScriptLocally(
176
234
func: BackendFunction,
@@ -179,6 +237,17 @@ export async function executeScriptLocally(
0 commit comments