IMQWrapCall interface

Around hook wrapping the actual service method invocation. It receives the request/response and a next callback that runs the method and resolves to its return value; it MUST call next() (returning its resolved value) to produce the response data. Unlike beforeCall/afterCall, this lets a hook run the method inside its own scope — e.g. establishing an OpenTelemetry context so any spans the method (and its downstream calls) create nest under the request span. When unset, the method is invoked directly.

Signature:

export interface IMQWrapCall<_T> 

Remarks

Service side only — there is no client equivalent, despite the type parameter.

The hook's resolved value is the response data. Calling next() exactly once and returning its value is the required pattern, but it is not enforced: omitting next() silently skips the method and returns your value instead, and calling it twice runs the method twice.

Unlike IMQBeforeCall and IMQAfterCall, errors here are not swallowed — anything this hook throws, or that propagates out of next(), becomes the call's error response (IMQ_RPC_CALL_ERROR, preserving the thrown error's own code when it has one). So a wrapping hook can safely let failures through or rethrow enriched errors.

Invoked bound to the service instance; this is untyped, so do not use an arrow function if you need it.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.