@camunda8/sdk
Version:
[](https://www.npmjs.com/package/@camunda8/sdk)
22 lines (21 loc) • 1.26 kB
TypeScript
import { AsyncLocalStorage } from 'node:async_hooks';
/**
* Capturing useful async stack traces is challenging with got.
* See here: https://github.com/sindresorhus/got/blob/main/documentation/async-stack-traces.md
* This function stores the call point from the application of got requests.
* This enables users to see where the error originated from.
* It uses the AsyncLocalStorage to store the creation stack trace.
* The stack trace is captured from the point where this function is called, allowing you to see where the async operation was initiated.
* See QuerySubscription.spec.ts for an example of how to use this function.
* @param fn The function to run within the async context. It can return a value or a Promise.
* @param errorTag A meaningful tag to identify the error context, which will be included in the stack trace.
* @returns
*/
export declare function runWithAsyncErrorContext<T>(fn: () => T | Promise<T>, errorTag: string): T | Promise<T>;
/**
* This is the exported AsyncLocalStorage instance that holds the context for async operations.
* It is used in the GotHooks.ts to extract the stack trace of the async operation.
*/
export declare const asyncOperationContext: AsyncLocalStorage<{
creationStack: string;
}>;