Skip to Content
HeronJS v4 is now available.
Versionv4UtilitiesReactive Execution

Reactive execution

RxJS remains the shared execution layer. ExecutionResult<T> accepts a value, Promise, Observable, or Promise resolving to an Observable. Protocol SDKs retain their native Promise interfaces at the transport boundary.

Reactive.call({ fn, context, args }) is cold: it invokes the function once per subscription, preserves this, and sends synchronous exceptions through the error channel. null, undefined, arrays, and strings are scalar results. Reactive.toObservable(result) normalizes an existing result; pass a function to Reactive.call when invocation itself must be deferred.

BoundaryConsumption
REST, GraphQL resolvers, tRPC queries/mutationsFirst emission, then unsubscribe
WebSocket decorated handlersFirst emission in the existing reply envelope
MCP tools/resources/prompts and ACP handlersFirst emission, then native SDK result validation
Worker jobs and parent-service RPCFirst emission
EBS consumers and finite lifecycle hooksWait for completion
EBS streams, tRPC subscriptions, worker servicesEvery emission until completion/cancellation
CQRS command/query busesPublic Observable results

Reactive.first({source, signal}) rejects empty completion with EmptyExecutionError (EMPTY_RESULT). An emitted undefined or null remains a value, subject to the target protocol’s result requirements. Cancellation rejects with ExecutionCancelledError (CANCELLED). Reactive.complete({source, signal}) waits for completion, ignores emitted values, and accepts an empty source.

Request disconnect, protocol cancellation, and application shutdown unsubscribe owned Observable executions. Native Promises need cooperative cancellation in application code. Worker jobs retain their slot until a cancelled Promise settles, or terminate the worker after its grace period. Infinite streams belong in APIs that explicitly support streaming; a unary source must emit or be cancelled.

dispatchAndWait() now actually waits and propagates errors. Dispatch helpers return subscriptions where applicable, and background execution reports errors. Event subscriptions have owners; event disposal completes Subjects. Finite service hooks are awaited, daemon subscriptions are tracked, and interval services skip a tick while the previous run is active. Existing @Service classes remain on the main thread.

EBS consumers normalize handlers before treating work as settled, preserving manual acknowledgement policy. EBS stream publishing remains ordered; publishing failures propagate, empty sources complete normally, and StreamerInput.signal cancels subscriptions. End hooks run after in-flight publishes settle. Application shutdown also cancels extension-owned streams and consumer subscriptions.

Class and method guards both apply. Shared guard evaluation awaits promised requirements and predicate results, supports Observable predicates, and denies missing identity, mismatches, empty predicates, and failed evaluation.

Protocol queue limits

WebSocket dispatch and writes, ACP prompt updates, and MCP execution and notification production use bounded queues. Observe cancellation and await sends or updates so failures and cleanup propagate. Configure limits on the endpoint decorators; see WebSocket, ACP, and MCP. MCP production limits do not bound the SDK’s internal HTTP SSE output buffer.

Repeated and inherited guards all apply with AND semantics. Predicates must produce exactly true; empty or invalid policies are rejected. See Authorization.

Last updated on