runWithRequest() function

Runs the given function with request bound to the current async execution context, so any code reached from it (and its asynchronous continuations) can access the in-flight request's metadata via currentMetadata() without threading it through call signatures.

The binding is scoped to the function: it is established for the duration of the call and automatically removed afterwards, which keeps concurrent requests isolated from one another.

Signature:

export declare function runWithRequest<T>(request: IMQRPCRequest, fn: () => T): T;

Parameters

Parameter

Type

Description

request

IMQRPCRequest

the request to bind for this execution

fn

() => T

the work to run within the bound context

Returns:

T

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