UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

82 lines (81 loc) 3.31 kB
import type { Node } from 'constructs'; /** * Captures the current process' stack trace. * * Stack traces are often invaluable tools to help diagnose problems, however * their capture is a rather expensive operation, and the stack traces can be * large. Consequently, callers of this code should give the user an ability * to opt out of call stack capturing. * * Most commonly, use the `debugModeEnabled()` function to turn them on or off. * * @param below an optional function starting from which stack frames will be * ignored. Defaults to the `captureStackTrace` function itself. * @param limit and optional upper bound to the number of stack frames to be * captured. If not provided, this defaults to * `Number.MAX_SAFE_INTEGER`, effectively meaning "no limit". * * @returns the captured stack trace, as an array of stack frames. */ export declare function captureStackTrace(below?: Function, limit?: number): string[]; /** * Capture a call stack using `Error.captureStackTrace` * * Modern Nodes have a `util.getCallSites()` API but: * * - it's heavily unstable; and * - source map support works by hijacking `Error.prepareStackTrace`. * * It's easier for us to render a regular stacktrace as a string, have source map support * do the right thing, and then pick it apart, than to try and reconstruct it. */ export declare function captureCallStack(upTo: Function | undefined): CallSite[]; /** * Parse the `error.stack` string into constituent components * * The string looks like this: * * ``` * Error: Some Error message * Potentially spread over multiple lines * at <function> (<file>:<line>:<col>) * at <function> (<file>:<line>:<col>) * at <class>.<function> (<file>:<line>:<col>) * at Object.<anonymous> (<file>:<line>:<col>) * at <function> [as somethingElse] (<file>:<line>:<col>) * at new <constructor> (<file>:<line>:<col>) * at <file>:<line>:<col> * ``` * * `<file>` can be `node:internal/modules/whatever`. */ export declare function parseErrorStack(stack: string): CallSite[]; /** * Renders an array of CallSites nicely, focusing on the user application code * * We detect "Not My Code" using the following heuristics: * * - If there is '/node_modules/' in the file path, we assume the call stack is a library and we skip it. * - If there is 'node:' in the file path, we assume it is NodeJS internals and we skip it. */ export declare function renderCallStackJustMyCode(stack: CallSite[], indent?: boolean): string[]; interface CallSite { functionName: string; fileName: string; sourceLocation: string; } /** * Records a metadata entry on a construct node to trace a property assignment. * * When debug mode is enabled (via the `CDK_DEBUG` environment variable), * this attaches `aws:cdk:propertyAssignment` metadata to the given node, * including a stack trace pointing back to the caller. This is useful for * diagnosing where a particular property value was set during synthesis. * * This is a no-op when debug mode is not enabled. * * @param node the construct node to attach the metadata to. * @param propertyName the name of the property being assigned. */ export declare function traceProperty(node: Node, propertyName: string): void; export {};