Skip to Content
HeronJS v4 is now available.
4.0.0UtilitiesReactive 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() waits for completion 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.


Based on 4.0.0 release source  (4.0.0).

Last updated on