MCPcopy Create free account
hub / github.com/electric-sql/electric / executeSend

Function executeSend

packages/agents-runtime/src/process-wake.ts:1327–1362  ·  view source on GitHub ↗
(send: {
      targetUrl: string
      payload: unknown
      type?: string
      afterMs?: number
    })

Source from the content-addressed store, hash-verified

1325
1326 // ---- Send executor — ctx.send() calls this directly (no queue) ----
1327 const executeSend = (send: {
1328 targetUrl: string
1329 payload: unknown
1330 type?: string
1331 afterMs?: number
1332 }): Promise<SendResult> => {
1333 if (
1334 send.afterMs !== undefined &&
1335 (!Number.isFinite(send.afterMs) || send.afterMs < 0)
1336 ) {
1337 const promise = Promise.reject<SendResult>(
1338 new Error(`afterMs must be a non-negative finite number`)
1339 )
1340 void promise.catch(() => undefined)
1341 return promise
1342 }
1343
1344 const promise = serverClient
1345 .sendEntityMessage({
1346 targetUrl: send.targetUrl,
1347 payload: send.payload,
1348 type: send.type,
1349 afterMs: send.afterMs,
1350 fromPrincipal: notification.principal?.url,
1351 fromAgent: entityUrl,
1352 writeToken,
1353 })
1354 .then(() => ({ sent: true as const, targetUrl: send.targetUrl }))
1355
1356 // Handlers may intentionally fire-and-forget sends. Keep awaited sends
1357 // rejectable, but mark ignored send failures as handled so they don't
1358 // surface as process/Vitest unhandled rejections.
1359 void promise.catch(() => undefined)
1360
1361 return promise
1362 }
1363
1364 // ---- Wiring helpers for inline spawn/observe ----
1365 const wiringConfig = {

Callers 2

doObserveFunction · 0.85
processWakeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected