From 381748a000fe0812888ced170c87d352a3d0944b Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 7 Dec 2022 21:19:14 +0000 Subject: [PATCH 01/19] Add untested integration --- packages/node/src/integrations/inspector.d.ts | 3359 +++++++++++++++++ .../node/src/integrations/localvariables.ts | 135 + packages/node/src/sdk.ts | 10 + packages/node/src/types.ts | 3 + 4 files changed, 3507 insertions(+) create mode 100644 packages/node/src/integrations/inspector.d.ts create mode 100644 packages/node/src/integrations/localvariables.ts diff --git a/packages/node/src/integrations/inspector.d.ts b/packages/node/src/integrations/inspector.d.ts new file mode 100644 index 000000000000..8128d2ad14f7 --- /dev/null +++ b/packages/node/src/integrations/inspector.d.ts @@ -0,0 +1,3359 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/unified-signatures */ +/* eslint-disable @typescript-eslint/explicit-member-accessibility */ +/* eslint-disable max-lines */ +/* eslint-disable @typescript-eslint/ban-types */ +// Type definitions for inspector + +// These definitions were copied from: +// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d37bf642ed2f3fe403e405892e2eb4240a191bb0/types/node/inspector.d.ts + +/** + * The `inspector` module provides an API for interacting with the V8 inspector. + * + * It can be accessed using: + * + * ```js + * const inspector = require('inspector'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js) + */ +declare module 'inspector' { + import EventEmitter = require('node:events'); + interface InspectorNotification { + method: string; + params: T; + } + namespace Schema { + /** + * Description of the protocol domain. + */ + interface Domain { + /** + * Domain name. + */ + name: string; + /** + * Domain version. + */ + version: string; + } + interface GetDomainsReturnType { + /** + * List of supported domains. + */ + domains: Domain[]; + } + } + namespace Runtime { + /** + * Unique script identifier. + */ + type ScriptId = string; + /** + * Unique object identifier. + */ + type RemoteObjectId = string; + /** + * Primitive value which cannot be JSON-stringified. + */ + type UnserializableValue = string; + /** + * Mirror object referencing original JavaScript object. + */ + interface RemoteObject { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * Object class (constructor) name. Specified for object type values only. + */ + className?: string | undefined; + /** + * Remote object value in case of primitive values or JSON values (if it was requested). + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified does not have value, but gets this property. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * Unique object identifier (for non-primitive values). + */ + objectId?: RemoteObjectId | undefined; + /** + * Preview containing abbreviated property values. Specified for object type values only. + * @experimental + */ + preview?: ObjectPreview | undefined; + /** + * @experimental + */ + customPreview?: CustomPreview | undefined; + } + /** + * @experimental + */ + interface CustomPreview { + header: string; + hasBody: boolean; + formatterObjectId: RemoteObjectId; + bindRemoteObjectFunctionId: RemoteObjectId; + configObjectId?: RemoteObjectId | undefined; + } + /** + * Object containing abbreviated remote object value. + * @experimental + */ + interface ObjectPreview { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * True iff some of the properties or entries of the original object did not fit. + */ + overflow: boolean; + /** + * List of the properties. + */ + properties: PropertyPreview[]; + /** + * List of the entries. Specified for map and set subtype values only. + */ + entries?: EntryPreview[] | undefined; + } + /** + * @experimental + */ + interface PropertyPreview { + /** + * Property name. + */ + name: string; + /** + * Object type. Accessor means that the property itself is an accessor property. + */ + type: string; + /** + * User-friendly property value string. + */ + value?: string | undefined; + /** + * Nested value preview. + */ + valuePreview?: ObjectPreview | undefined; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + } + /** + * @experimental + */ + interface EntryPreview { + /** + * Preview of the key. Specified for map-like collection entries. + */ + key?: ObjectPreview | undefined; + /** + * Preview of the value. + */ + value: ObjectPreview; + } + /** + * Object property descriptor. + */ + interface PropertyDescriptor { + /** + * Property name or symbol description. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + /** + * True if the value associated with the property may be changed (data descriptors only). + */ + writable?: boolean | undefined; + /** + * A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only). + */ + get?: RemoteObject | undefined; + /** + * A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only). + */ + set?: RemoteObject | undefined; + /** + * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. + */ + configurable: boolean; + /** + * True if this property shows up during enumeration of the properties on the corresponding object. + */ + enumerable: boolean; + /** + * True if the result was thrown during the evaluation. + */ + wasThrown?: boolean | undefined; + /** + * True if the property is owned for the object. + */ + isOwn?: boolean | undefined; + /** + * Property symbol object, if the property is of the symbol type. + */ + symbol?: RemoteObject | undefined; + } + /** + * Object internal property descriptor. This property isn't normally visible in JavaScript code. + */ + interface InternalPropertyDescriptor { + /** + * Conventional property name. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + } + /** + * Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified. + */ + interface CallArgument { + /** + * Primitive value or serializable javascript object. + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * Remote object handle. + */ + objectId?: RemoteObjectId | undefined; + } + /** + * Id of an execution context. + */ + type ExecutionContextId = number; + /** + * Description of an isolated world. + */ + interface ExecutionContextDescription { + /** + * Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed. + */ + id: ExecutionContextId; + /** + * Execution context origin. + */ + origin: string; + /** + * Human readable name describing given context. + */ + name: string; + /** + * Embedder-specific auxiliary data. + */ + auxData?: {} | undefined; + } + /** + * Detailed information about exception (or error) that was thrown during script compilation or execution. + */ + interface ExceptionDetails { + /** + * Exception id. + */ + exceptionId: number; + /** + * Exception text, which should be used together with exception object when available. + */ + text: string; + /** + * Line number of the exception location (0-based). + */ + lineNumber: number; + /** + * Column number of the exception location (0-based). + */ + columnNumber: number; + /** + * Script ID of the exception location. + */ + scriptId?: ScriptId | undefined; + /** + * URL of the exception location, to be used when the script was not reported. + */ + url?: string | undefined; + /** + * JavaScript stack trace if available. + */ + stackTrace?: StackTrace | undefined; + /** + * Exception object if available. + */ + exception?: RemoteObject | undefined; + /** + * Identifier of the context where exception happened. + */ + executionContextId?: ExecutionContextId | undefined; + } + /** + * Number of milliseconds since epoch. + */ + type Timestamp = number; + /** + * Stack entry for runtime errors and assertions. + */ + interface CallFrame { + /** + * JavaScript function name. + */ + functionName: string; + /** + * JavaScript script id. + */ + scriptId: ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * JavaScript script line number (0-based). + */ + lineNumber: number; + /** + * JavaScript script column number (0-based). + */ + columnNumber: number; + } + /** + * Call frames for assertions or error messages. + */ + interface StackTrace { + /** + * String label of this stack trace. For async traces this may be a name of the function that initiated the async call. + */ + description?: string | undefined; + /** + * JavaScript function name. + */ + callFrames: CallFrame[]; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + */ + parent?: StackTrace | undefined; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + * @experimental + */ + parentId?: StackTraceId | undefined; + } + /** + * Unique identifier of current debugger. + * @experimental + */ + type UniqueDebuggerId = string; + /** + * If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages. + * @experimental + */ + interface StackTraceId { + id: string; + debuggerId?: UniqueDebuggerId | undefined; + } + interface EvaluateParameterType { + /** + * Expression to evaluate. + */ + expression: string; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + contextId?: ExecutionContextId | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface AwaitPromiseParameterType { + /** + * Identifier of the promise. + */ + promiseObjectId: RemoteObjectId; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + } + interface CallFunctionOnParameterType { + /** + * Declaration of the function to call. + */ + functionDeclaration: string; + /** + * Identifier of the object to call function on. Either objectId or executionContextId should be specified. + */ + objectId?: RemoteObjectId | undefined; + /** + * Call arguments. All call arguments must belong to the same JavaScript world as the target object. + */ + arguments?: CallArgument[] | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + /** + * Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object. + */ + objectGroup?: string | undefined; + } + interface GetPropertiesParameterType { + /** + * Identifier of the object to return properties for. + */ + objectId: RemoteObjectId; + /** + * If true, returns properties belonging only to the element itself, not to its prototype chain. + */ + ownProperties?: boolean | undefined; + /** + * If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. + * @experimental + */ + accessorPropertiesOnly?: boolean | undefined; + /** + * Whether preview should be generated for the results. + * @experimental + */ + generatePreview?: boolean | undefined; + } + interface ReleaseObjectParameterType { + /** + * Identifier of the object to release. + */ + objectId: RemoteObjectId; + } + interface ReleaseObjectGroupParameterType { + /** + * Symbolic object group name. + */ + objectGroup: string; + } + interface SetCustomObjectFormatterEnabledParameterType { + enabled: boolean; + } + interface CompileScriptParameterType { + /** + * Expression to compile. + */ + expression: string; + /** + * Source url to be set for the script. + */ + sourceURL: string; + /** + * Specifies whether the compiled script should be persisted. + */ + persistScript: boolean; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface RunScriptParameterType { + /** + * Id of the script to run. + */ + scriptId: ScriptId; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface QueryObjectsParameterType { + /** + * Identifier of the prototype to return objects for. + */ + prototypeObjectId: RemoteObjectId; + } + interface GlobalLexicalScopeNamesParameterType { + /** + * Specifies in which execution context to lookup global scope variables. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface EvaluateReturnType { + /** + * Evaluation result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface AwaitPromiseReturnType { + /** + * Promise result. Will contain rejected value if promise was rejected. + */ + result: RemoteObject; + /** + * Exception details if stack strace is available. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CallFunctionOnReturnType { + /** + * Call result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface GetPropertiesReturnType { + /** + * Object properties. + */ + result: PropertyDescriptor[]; + /** + * Internal object properties (only of the element itself). + */ + internalProperties?: InternalPropertyDescriptor[] | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CompileScriptReturnType { + /** + * Id of the script. + */ + scriptId?: ScriptId | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface RunScriptReturnType { + /** + * Run result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface QueryObjectsReturnType { + /** + * Array with objects. + */ + objects: RemoteObject; + } + interface GlobalLexicalScopeNamesReturnType { + names: string[]; + } + interface ExecutionContextCreatedEventDataType { + /** + * A newly created execution context. + */ + context: ExecutionContextDescription; + } + interface ExecutionContextDestroyedEventDataType { + /** + * Id of the destroyed context + */ + executionContextId: ExecutionContextId; + } + interface ExceptionThrownEventDataType { + /** + * Timestamp of the exception. + */ + timestamp: Timestamp; + exceptionDetails: ExceptionDetails; + } + interface ExceptionRevokedEventDataType { + /** + * Reason describing why exception was revoked. + */ + reason: string; + /** + * The id of revoked exception, as reported in exceptionThrown. + */ + exceptionId: number; + } + interface ConsoleAPICalledEventDataType { + /** + * Type of the call. + */ + type: string; + /** + * Call arguments. + */ + args: RemoteObject[]; + /** + * Identifier of the context where the call was made. + */ + executionContextId: ExecutionContextId; + /** + * Call timestamp. + */ + timestamp: Timestamp; + /** + * Stack trace captured when the call was made. + */ + stackTrace?: StackTrace | undefined; + /** + * Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context. + * @experimental + */ + context?: string | undefined; + } + interface InspectRequestedEventDataType { + object: RemoteObject; + hints: {}; + } + } + namespace Debugger { + /** + * Breakpoint identifier. + */ + type BreakpointId = string; + /** + * Call frame identifier. + */ + type CallFrameId = string; + /** + * Location in the source code. + */ + interface Location { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + } + /** + * Location in the source code. + * @experimental + */ + interface ScriptPosition { + lineNumber: number; + columnNumber: number; + } + /** + * JavaScript call frame. Array of call frames form the call stack. + */ + interface CallFrame { + /** + * Call frame identifier. This identifier is only valid while the virtual machine is paused. + */ + callFrameId: CallFrameId; + /** + * Name of the JavaScript function called on this call frame. + */ + functionName: string; + /** + * Location in the source code. + */ + functionLocation?: Location | undefined; + /** + * Location in the source code. + */ + location: Location; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Scope chain for this call frame. + */ + scopeChain: Scope[]; + /** + * this object for this call frame. + */ + this: Runtime.RemoteObject; + /** + * The value being returned, if the function is at return point. + */ + returnValue?: Runtime.RemoteObject | undefined; + } + /** + * Scope description. + */ + interface Scope { + /** + * Scope type. + */ + type: string; + /** + * Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties. + */ + object: Runtime.RemoteObject; + name?: string | undefined; + /** + * Location in the source code where scope starts + */ + startLocation?: Location | undefined; + /** + * Location in the source code where scope ends + */ + endLocation?: Location | undefined; + } + /** + * Search match for resource. + */ + interface SearchMatch { + /** + * Line number in resource content. + */ + lineNumber: number; + /** + * Line with match content. + */ + lineContent: string; + } + interface BreakLocation { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + type?: string | undefined; + } + interface SetBreakpointsActiveParameterType { + /** + * New value for breakpoints active state. + */ + active: boolean; + } + interface SetSkipAllPausesParameterType { + /** + * New value for skip pauses state. + */ + skip: boolean; + } + interface SetBreakpointByUrlParameterType { + /** + * Line number to set breakpoint at. + */ + lineNumber: number; + /** + * URL of the resources to set breakpoint on. + */ + url?: string | undefined; + /** + * Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. + */ + urlRegex?: string | undefined; + /** + * Script hash of the resources to set breakpoint on. + */ + scriptHash?: string | undefined; + /** + * Offset in the line to set breakpoint at. + */ + columnNumber?: number | undefined; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface SetBreakpointParameterType { + /** + * Location to set breakpoint in. + */ + location: Location; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface RemoveBreakpointParameterType { + breakpointId: BreakpointId; + } + interface GetPossibleBreakpointsParameterType { + /** + * Start of range to search possible breakpoint locations in. + */ + start: Location; + /** + * End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. + */ + end?: Location | undefined; + /** + * Only consider locations which are in the same (non-nested) function as start. + */ + restrictToFunction?: boolean | undefined; + } + interface ContinueToLocationParameterType { + /** + * Location to continue to. + */ + location: Location; + targetCallFrames?: string | undefined; + } + interface PauseOnAsyncCallParameterType { + /** + * Debugger will pause when async call with given stack trace is started. + */ + parentStackTraceId: Runtime.StackTraceId; + } + interface StepIntoParameterType { + /** + * Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. + * @experimental + */ + breakOnAsyncCall?: boolean | undefined; + } + interface GetStackTraceParameterType { + stackTraceId: Runtime.StackTraceId; + } + interface SearchInContentParameterType { + /** + * Id of the script to search in. + */ + scriptId: Runtime.ScriptId; + /** + * String to search for. + */ + query: string; + /** + * If true, search is case sensitive. + */ + caseSensitive?: boolean | undefined; + /** + * If true, treats string parameter as regex. + */ + isRegex?: boolean | undefined; + } + interface SetScriptSourceParameterType { + /** + * Id of the script to edit. + */ + scriptId: Runtime.ScriptId; + /** + * New content of the script. + */ + scriptSource: string; + /** + * If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. + */ + dryRun?: boolean | undefined; + } + interface RestartFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + } + interface GetScriptSourceParameterType { + /** + * Id of the script to get source for. + */ + scriptId: Runtime.ScriptId; + } + interface SetPauseOnExceptionsParameterType { + /** + * Pause on exceptions mode. + */ + state: string; + } + interface EvaluateOnCallFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + /** + * Expression to evaluate. + */ + expression: string; + /** + * String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup). + */ + objectGroup?: string | undefined; + /** + * Specifies whether command line API should be available to the evaluated expression, defaults to false. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether to throw an exception if side effect cannot be ruled out during evaluation. + */ + throwOnSideEffect?: boolean | undefined; + } + interface SetVariableValueParameterType { + /** + * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. + */ + scopeNumber: number; + /** + * Variable name. + */ + variableName: string; + /** + * New variable value. + */ + newValue: Runtime.CallArgument; + /** + * Id of callframe that holds variable. + */ + callFrameId: CallFrameId; + } + interface SetReturnValueParameterType { + /** + * New return value. + */ + newValue: Runtime.CallArgument; + } + interface SetAsyncCallStackDepthParameterType { + /** + * Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default). + */ + maxDepth: number; + } + interface SetBlackboxPatternsParameterType { + /** + * Array of regexps that will be used to check script url for blackbox state. + */ + patterns: string[]; + } + interface SetBlackboxedRangesParameterType { + /** + * Id of the script. + */ + scriptId: Runtime.ScriptId; + positions: ScriptPosition[]; + } + interface EnableReturnType { + /** + * Unique identifier of the debugger. + * @experimental + */ + debuggerId: Runtime.UniqueDebuggerId; + } + interface SetBreakpointByUrlReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * List of the locations this breakpoint resolved into upon addition. + */ + locations: Location[]; + } + interface SetBreakpointReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * Location this breakpoint resolved into. + */ + actualLocation: Location; + } + interface GetPossibleBreakpointsReturnType { + /** + * List of the possible breakpoint locations. + */ + locations: BreakLocation[]; + } + interface GetStackTraceReturnType { + stackTrace: Runtime.StackTrace; + } + interface SearchInContentReturnType { + /** + * List of search matches. + */ + result: SearchMatch[]; + } + interface SetScriptSourceReturnType { + /** + * New stack trace in case editing has happened while VM was stopped. + */ + callFrames?: CallFrame[] | undefined; + /** + * Whether current call stack was modified after applying the changes. + */ + stackChanged?: boolean | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Exception details if any. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface RestartFrameReturnType { + /** + * New stack trace. + */ + callFrames: CallFrame[]; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + } + interface GetScriptSourceReturnType { + /** + * Script source. + */ + scriptSource: string; + } + interface EvaluateOnCallFrameReturnType { + /** + * Object wrapper for the evaluation result. + */ + result: Runtime.RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface ScriptParsedEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * True, if this script is generated as a result of the live edit operation. + * @experimental + */ + isLiveEdit?: boolean | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface ScriptFailedToParseEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface BreakpointResolvedEventDataType { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } + interface PausedEventDataType { + /** + * Call stack the virtual machine stopped on. + */ + callFrames: CallFrame[]; + /** + * Pause reason. + */ + reason: string; + /** + * Object containing break-specific auxiliary properties. + */ + data?: {} | undefined; + /** + * Hit breakpoints IDs + */ + hitBreakpoints?: string[] | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag. + * @experimental + */ + asyncCallStackTraceId?: Runtime.StackTraceId | undefined; + } + } + namespace Console { + /** + * Console message. + */ + interface ConsoleMessage { + /** + * Message source. + */ + source: string; + /** + * Message severity. + */ + level: string; + /** + * Message text. + */ + text: string; + /** + * URL of the message origin. + */ + url?: string | undefined; + /** + * Line number in the resource that generated this message (1-based). + */ + line?: number | undefined; + /** + * Column number in the resource that generated this message (1-based). + */ + column?: number | undefined; + } + interface MessageAddedEventDataType { + /** + * Console message that has been added. + */ + message: ConsoleMessage; + } + } + namespace Profiler { + /** + * Profile node. Holds callsite information, execution statistics and child nodes. + */ + interface ProfileNode { + /** + * Unique id of the node. + */ + id: number; + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Number of samples where this node was on top of the call stack. + */ + hitCount?: number | undefined; + /** + * Child node ids. + */ + children?: number[] | undefined; + /** + * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. + */ + deoptReason?: string | undefined; + /** + * An array of source position ticks. + */ + positionTicks?: PositionTickInfo[] | undefined; + } + /** + * Profile. + */ + interface Profile { + /** + * The list of profile nodes. First item is the root node. + */ + nodes: ProfileNode[]; + /** + * Profiling start timestamp in microseconds. + */ + startTime: number; + /** + * Profiling end timestamp in microseconds. + */ + endTime: number; + /** + * Ids of samples top nodes. + */ + samples?: number[] | undefined; + /** + * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. + */ + timeDeltas?: number[] | undefined; + } + /** + * Specifies a number of samples attributed to a certain source position. + */ + interface PositionTickInfo { + /** + * Source line number (1-based). + */ + line: number; + /** + * Number of samples attributed to the source line. + */ + ticks: number; + } + /** + * Coverage data for a source range. + */ + interface CoverageRange { + /** + * JavaScript script source offset for the range start. + */ + startOffset: number; + /** + * JavaScript script source offset for the range end. + */ + endOffset: number; + /** + * Collected execution count of the source range. + */ + count: number; + } + /** + * Coverage data for a JavaScript function. + */ + interface FunctionCoverage { + /** + * JavaScript function name. + */ + functionName: string; + /** + * Source ranges inside the function with coverage data. + */ + ranges: CoverageRange[]; + /** + * Whether coverage data for this function has block granularity. + */ + isBlockCoverage: boolean; + } + /** + * Coverage data for a JavaScript script. + */ + interface ScriptCoverage { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Functions contained in the script that has coverage data. + */ + functions: FunctionCoverage[]; + } + /** + * Describes a type collected during runtime. + * @experimental + */ + interface TypeObject { + /** + * Name of a type collected with type profiling. + */ + name: string; + } + /** + * Source offset and types for a parameter or return value. + * @experimental + */ + interface TypeProfileEntry { + /** + * Source offset of the parameter or end of function for return values. + */ + offset: number; + /** + * The types for this parameter or return value. + */ + types: TypeObject[]; + } + /** + * Type profile data collected during runtime for a JavaScript script. + * @experimental + */ + interface ScriptTypeProfile { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Type profile entries for parameters and return values of the functions in the script. + */ + entries: TypeProfileEntry[]; + } + interface SetSamplingIntervalParameterType { + /** + * New sampling interval in microseconds. + */ + interval: number; + } + interface StartPreciseCoverageParameterType { + /** + * Collect accurate call counts beyond simple 'covered' or 'not covered'. + */ + callCount?: boolean | undefined; + /** + * Collect block-based coverage. + */ + detailed?: boolean | undefined; + } + interface StopReturnType { + /** + * Recorded profile. + */ + profile: Profile; + } + interface TakePreciseCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface GetBestEffortCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface TakeTypeProfileReturnType { + /** + * Type profile for all scripts since startTypeProfile() was turned on. + */ + result: ScriptTypeProfile[]; + } + interface ConsoleProfileStartedEventDataType { + id: string; + /** + * Location of console.profile(). + */ + location: Debugger.Location; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + interface ConsoleProfileFinishedEventDataType { + id: string; + /** + * Location of console.profileEnd(). + */ + location: Debugger.Location; + profile: Profile; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + } + namespace HeapProfiler { + /** + * Heap snapshot object id. + */ + type HeapSnapshotObjectId = string; + /** + * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. + */ + interface SamplingHeapProfileNode { + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Allocations size in bytes for the node excluding children. + */ + selfSize: number; + /** + * Child nodes. + */ + children: SamplingHeapProfileNode[]; + } + /** + * Profile. + */ + interface SamplingHeapProfile { + head: SamplingHeapProfileNode; + } + interface StartTrackingHeapObjectsParameterType { + trackAllocations?: boolean | undefined; + } + interface StopTrackingHeapObjectsParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. + */ + reportProgress?: boolean | undefined; + } + interface TakeHeapSnapshotParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. + */ + reportProgress?: boolean | undefined; + } + interface GetObjectByHeapObjectIdParameterType { + objectId: HeapSnapshotObjectId; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + } + interface AddInspectedHeapObjectParameterType { + /** + * Heap snapshot object id to be accessible by means of $x command line API. + */ + heapObjectId: HeapSnapshotObjectId; + } + interface GetHeapObjectIdParameterType { + /** + * Identifier of the object to get heap object id for. + */ + objectId: Runtime.RemoteObjectId; + } + interface StartSamplingParameterType { + /** + * Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. + */ + samplingInterval?: number | undefined; + } + interface GetObjectByHeapObjectIdReturnType { + /** + * Evaluation result. + */ + result: Runtime.RemoteObject; + } + interface GetHeapObjectIdReturnType { + /** + * Id of the heap snapshot object corresponding to the passed remote object id. + */ + heapSnapshotObjectId: HeapSnapshotObjectId; + } + interface StopSamplingReturnType { + /** + * Recorded sampling heap profile. + */ + profile: SamplingHeapProfile; + } + interface GetSamplingProfileReturnType { + /** + * Return the sampling profile being collected. + */ + profile: SamplingHeapProfile; + } + interface AddHeapSnapshotChunkEventDataType { + chunk: string; + } + interface ReportHeapSnapshotProgressEventDataType { + done: number; + total: number; + finished?: boolean | undefined; + } + interface LastSeenObjectIdEventDataType { + lastSeenObjectId: number; + timestamp: number; + } + interface HeapStatsUpdateEventDataType { + /** + * An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. + */ + statsUpdate: number[]; + } + } + namespace NodeTracing { + interface TraceConfig { + /** + * Controls how the trace buffer stores data. + */ + recordMode?: string | undefined; + /** + * Included category filters. + */ + includedCategories: string[]; + } + interface StartParameterType { + traceConfig: TraceConfig; + } + interface GetCategoriesReturnType { + /** + * A list of supported tracing categories. + */ + categories: string[]; + } + interface DataCollectedEventDataType { + value: Array<{}>; + } + } + namespace NodeWorker { + type WorkerID = string; + /** + * Unique identifier of attached debugging session. + */ + type SessionID = string; + interface WorkerInfo { + workerId: WorkerID; + type: string; + title: string; + url: string; + } + interface SendMessageToWorkerParameterType { + message: string; + /** + * Identifier of the session. + */ + sessionId: SessionID; + } + interface EnableParameterType { + /** + * Whether to new workers should be paused until the frontend sends `Runtime.runIfWaitingForDebugger` + * message to run them. + */ + waitForDebuggerOnStart: boolean; + } + interface DetachParameterType { + sessionId: SessionID; + } + interface AttachedToWorkerEventDataType { + /** + * Identifier assigned to the session used to send/receive messages. + */ + sessionId: SessionID; + workerInfo: WorkerInfo; + waitingForDebugger: boolean; + } + interface DetachedFromWorkerEventDataType { + /** + * Detached session identifier. + */ + sessionId: SessionID; + } + interface ReceivedMessageFromWorkerEventDataType { + /** + * Identifier of a session which sends a message. + */ + sessionId: SessionID; + message: string; + } + } + namespace NodeRuntime { + interface NotifyWhenWaitingForDisconnectParameterType { + enabled: boolean; + } + } + /** + * The `inspector.Session` is used for dispatching messages to the V8 inspector + * back-end and receiving message responses and notifications. + */ + class Session extends EventEmitter { + /** + * Create a new instance of the inspector.Session class. + * The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend. + */ + constructor(); + /** + * Connects a session to the inspector back-end. + * @since v8.0.0 + */ + connect(): void; + /** + * Immediately close the session. All pending message callbacks will be called + * with an error. `session.connect()` will need to be called to be able to send + * messages again. Reconnected session will lose all inspector state, such as + * enabled agents or configured breakpoints. + * @since v8.0.0 + */ + disconnect(): void; + /** + * Posts a message to the inspector back-end. `callback` will be notified when + * a response is received. `callback` is a function that accepts two optional + * arguments: error and message-specific result. + * + * ```js + * session.post('Runtime.evaluate', { expression: '2 + 2' }, + * (error, { result }) => console.log(result)); + * // Output: { type: 'number', value: 4, description: '4' } + * ``` + * + * The latest version of the V8 inspector protocol is published on the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/v8/). + * + * Node.js inspector supports all the Chrome DevTools Protocol domains declared + * by V8\. Chrome DevTools Protocol domain provides an interface for interacting + * with one of the runtime agents used to inspect the application state and listen + * to the run-time events. + * + * ## Example usage + * + * Apart from the debugger, various V8 Profilers are available through the DevTools + * protocol. + * @since v8.0.0 + */ + post(method: string, params?: {}, callback?: (err: Error | null, params?: {}) => void): void; + post(method: string, callback?: (err: Error | null, params?: {}) => void): void; + /** + * Returns supported domains. + */ + post( + method: 'Schema.getDomains', + callback?: (err: Error | null, params: Schema.GetDomainsReturnType) => void, + ): void; + /** + * Evaluates expression on global object. + */ + post( + method: 'Runtime.evaluate', + params?: Runtime.EvaluateParameterType, + callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void, + ): void; + post(method: 'Runtime.evaluate', callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + /** + * Add handler to promise with given promise object id. + */ + post( + method: 'Runtime.awaitPromise', + params?: Runtime.AwaitPromiseParameterType, + callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, + ): void; + post( + method: 'Runtime.awaitPromise', + callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, + ): void; + /** + * Calls function with given declaration on the given object. Object group of the result is inherited from the target object. + */ + post( + method: 'Runtime.callFunctionOn', + params?: Runtime.CallFunctionOnParameterType, + callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, + ): void; + post( + method: 'Runtime.callFunctionOn', + callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, + ): void; + /** + * Returns properties of a given object. Object group of the result is inherited from the target object. + */ + post( + method: 'Runtime.getProperties', + params?: Runtime.GetPropertiesParameterType, + callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, + ): void; + post( + method: 'Runtime.getProperties', + callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, + ): void; + /** + * Releases remote object with given id. + */ + post( + method: 'Runtime.releaseObject', + params?: Runtime.ReleaseObjectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.releaseObject', callback?: (err: Error | null) => void): void; + /** + * Releases all remote objects that belong to a given group. + */ + post( + method: 'Runtime.releaseObjectGroup', + params?: Runtime.ReleaseObjectGroupParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.releaseObjectGroup', callback?: (err: Error | null) => void): void; + /** + * Tells inspected instance to run if it was waiting for debugger to attach. + */ + post(method: 'Runtime.runIfWaitingForDebugger', callback?: (err: Error | null) => void): void; + /** + * Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context. + */ + post(method: 'Runtime.enable', callback?: (err: Error | null) => void): void; + /** + * Disables reporting of execution contexts creation. + */ + post(method: 'Runtime.disable', callback?: (err: Error | null) => void): void; + /** + * Discards collected exceptions and console API calls. + */ + post(method: 'Runtime.discardConsoleEntries', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post( + method: 'Runtime.setCustomObjectFormatterEnabled', + params?: Runtime.SetCustomObjectFormatterEnabledParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.setCustomObjectFormatterEnabled', callback?: (err: Error | null) => void): void; + /** + * Compiles expression. + */ + post( + method: 'Runtime.compileScript', + params?: Runtime.CompileScriptParameterType, + callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, + ): void; + post( + method: 'Runtime.compileScript', + callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, + ): void; + /** + * Runs script with given id in a given context. + */ + post( + method: 'Runtime.runScript', + params?: Runtime.RunScriptParameterType, + callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, + ): void; + post( + method: 'Runtime.runScript', + callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, + ): void; + post( + method: 'Runtime.queryObjects', + params?: Runtime.QueryObjectsParameterType, + callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, + ): void; + post( + method: 'Runtime.queryObjects', + callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, + ): void; + /** + * Returns all let, const and class variables from global scope. + */ + post( + method: 'Runtime.globalLexicalScopeNames', + params?: Runtime.GlobalLexicalScopeNamesParameterType, + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, + ): void; + post( + method: 'Runtime.globalLexicalScopeNames', + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, + ): void; + /** + * Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received. + */ + post(method: 'Debugger.enable', callback?: (err: Error | null, params: Debugger.EnableReturnType) => void): void; + /** + * Disables debugger for given page. + */ + post(method: 'Debugger.disable', callback?: (err: Error | null) => void): void; + /** + * Activates / deactivates all breakpoints on the page. + */ + post( + method: 'Debugger.setBreakpointsActive', + params?: Debugger.SetBreakpointsActiveParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBreakpointsActive', callback?: (err: Error | null) => void): void; + /** + * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + */ + post( + method: 'Debugger.setSkipAllPauses', + params?: Debugger.SetSkipAllPausesParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setSkipAllPauses', callback?: (err: Error | null) => void): void; + /** + * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads. + */ + post( + method: 'Debugger.setBreakpointByUrl', + params?: Debugger.SetBreakpointByUrlParameterType, + callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, + ): void; + post( + method: 'Debugger.setBreakpointByUrl', + callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, + ): void; + /** + * Sets JavaScript breakpoint at a given location. + */ + post( + method: 'Debugger.setBreakpoint', + params?: Debugger.SetBreakpointParameterType, + callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, + ): void; + post( + method: 'Debugger.setBreakpoint', + callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, + ): void; + /** + * Removes JavaScript breakpoint. + */ + post( + method: 'Debugger.removeBreakpoint', + params?: Debugger.RemoveBreakpointParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.removeBreakpoint', callback?: (err: Error | null) => void): void; + /** + * Returns possible locations for breakpoint. scriptId in start and end range locations should be the same. + */ + post( + method: 'Debugger.getPossibleBreakpoints', + params?: Debugger.GetPossibleBreakpointsParameterType, + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, + ): void; + post( + method: 'Debugger.getPossibleBreakpoints', + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, + ): void; + /** + * Continues execution until specific location is reached. + */ + post( + method: 'Debugger.continueToLocation', + params?: Debugger.ContinueToLocationParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.continueToLocation', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post( + method: 'Debugger.pauseOnAsyncCall', + params?: Debugger.PauseOnAsyncCallParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.pauseOnAsyncCall', callback?: (err: Error | null) => void): void; + /** + * Steps over the statement. + */ + post(method: 'Debugger.stepOver', callback?: (err: Error | null) => void): void; + /** + * Steps into the function call. + */ + post( + method: 'Debugger.stepInto', + params?: Debugger.StepIntoParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.stepInto', callback?: (err: Error | null) => void): void; + /** + * Steps out of the function call. + */ + post(method: 'Debugger.stepOut', callback?: (err: Error | null) => void): void; + /** + * Stops on the next JavaScript statement. + */ + post(method: 'Debugger.pause', callback?: (err: Error | null) => void): void; + /** + * This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called. + * @experimental + */ + post(method: 'Debugger.scheduleStepIntoAsync', callback?: (err: Error | null) => void): void; + /** + * Resumes JavaScript execution. + */ + post(method: 'Debugger.resume', callback?: (err: Error | null) => void): void; + /** + * Returns stack trace with given stackTraceId. + * @experimental + */ + post( + method: 'Debugger.getStackTrace', + params?: Debugger.GetStackTraceParameterType, + callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, + ): void; + post( + method: 'Debugger.getStackTrace', + callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, + ): void; + /** + * Searches for given string in script content. + */ + post( + method: 'Debugger.searchInContent', + params?: Debugger.SearchInContentParameterType, + callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, + ): void; + post( + method: 'Debugger.searchInContent', + callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, + ): void; + /** + * Edits JavaScript source live. + */ + post( + method: 'Debugger.setScriptSource', + params?: Debugger.SetScriptSourceParameterType, + callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, + ): void; + post( + method: 'Debugger.setScriptSource', + callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, + ): void; + /** + * Restarts particular call frame from the beginning. + */ + post( + method: 'Debugger.restartFrame', + params?: Debugger.RestartFrameParameterType, + callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, + ): void; + post( + method: 'Debugger.restartFrame', + callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, + ): void; + /** + * Returns source for the script with given id. + */ + post( + method: 'Debugger.getScriptSource', + params?: Debugger.GetScriptSourceParameterType, + callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, + ): void; + post( + method: 'Debugger.getScriptSource', + callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, + ): void; + /** + * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none. + */ + post( + method: 'Debugger.setPauseOnExceptions', + params?: Debugger.SetPauseOnExceptionsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setPauseOnExceptions', callback?: (err: Error | null) => void): void; + /** + * Evaluates expression on a given call frame. + */ + post( + method: 'Debugger.evaluateOnCallFrame', + params?: Debugger.EvaluateOnCallFrameParameterType, + callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, + ): void; + post( + method: 'Debugger.evaluateOnCallFrame', + callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, + ): void; + /** + * Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually. + */ + post( + method: 'Debugger.setVariableValue', + params?: Debugger.SetVariableValueParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setVariableValue', callback?: (err: Error | null) => void): void; + /** + * Changes return value in top frame. Available only at return break position. + * @experimental + */ + post( + method: 'Debugger.setReturnValue', + params?: Debugger.SetReturnValueParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setReturnValue', callback?: (err: Error | null) => void): void; + /** + * Enables or disables async call stacks tracking. + */ + post( + method: 'Debugger.setAsyncCallStackDepth', + params?: Debugger.SetAsyncCallStackDepthParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setAsyncCallStackDepth', callback?: (err: Error | null) => void): void; + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + * @experimental + */ + post( + method: 'Debugger.setBlackboxPatterns', + params?: Debugger.SetBlackboxPatternsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBlackboxPatterns', callback?: (err: Error | null) => void): void; + /** + * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted. + * @experimental + */ + post( + method: 'Debugger.setBlackboxedRanges', + params?: Debugger.SetBlackboxedRangesParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBlackboxedRanges', callback?: (err: Error | null) => void): void; + /** + * Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification. + */ + post(method: 'Console.enable', callback?: (err: Error | null) => void): void; + /** + * Disables console domain, prevents further console messages from being reported to the client. + */ + post(method: 'Console.disable', callback?: (err: Error | null) => void): void; + /** + * Does nothing. + */ + post(method: 'Console.clearMessages', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.disable', callback?: (err: Error | null) => void): void; + /** + * Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + */ + post( + method: 'Profiler.setSamplingInterval', + params?: Profiler.SetSamplingIntervalParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Profiler.setSamplingInterval', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.start', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.stop', callback?: (err: Error | null, params: Profiler.StopReturnType) => void): void; + /** + * Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters. + */ + post( + method: 'Profiler.startPreciseCoverage', + params?: Profiler.StartPreciseCoverageParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Profiler.startPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code. + */ + post(method: 'Profiler.stopPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started. + */ + post( + method: 'Profiler.takePreciseCoverage', + callback?: (err: Error | null, params: Profiler.TakePreciseCoverageReturnType) => void, + ): void; + /** + * Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection. + */ + post( + method: 'Profiler.getBestEffortCoverage', + callback?: (err: Error | null, params: Profiler.GetBestEffortCoverageReturnType) => void, + ): void; + /** + * Enable type profile. + * @experimental + */ + post(method: 'Profiler.startTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Disable type profile. Disabling releases type profile data collected so far. + * @experimental + */ + post(method: 'Profiler.stopTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Collect type profile. + * @experimental + */ + post( + method: 'Profiler.takeTypeProfile', + callback?: (err: Error | null, params: Profiler.TakeTypeProfileReturnType) => void, + ): void; + post(method: 'HeapProfiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.disable', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.startTrackingHeapObjects', + params?: HeapProfiler.StartTrackingHeapObjectsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.stopTrackingHeapObjects', + params?: HeapProfiler.StopTrackingHeapObjectsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.takeHeapSnapshot', + params?: HeapProfiler.TakeHeapSnapshotParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.takeHeapSnapshot', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.collectGarbage', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + params?: HeapProfiler.GetObjectByHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, + ): void; + /** + * Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). + */ + post( + method: 'HeapProfiler.addInspectedHeapObject', + params?: HeapProfiler.AddInspectedHeapObjectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.addInspectedHeapObject', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getHeapObjectId', + params?: HeapProfiler.GetHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getHeapObjectId', + callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.startSampling', + params?: HeapProfiler.StartSamplingParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.startSampling', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.stopSampling', + callback?: (err: Error | null, params: HeapProfiler.StopSamplingReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getSamplingProfile', + callback?: (err: Error | null, params: HeapProfiler.GetSamplingProfileReturnType) => void, + ): void; + /** + * Gets supported tracing categories. + */ + post( + method: 'NodeTracing.getCategories', + callback?: (err: Error | null, params: NodeTracing.GetCategoriesReturnType) => void, + ): void; + /** + * Start trace events collection. + */ + post( + method: 'NodeTracing.start', + params?: NodeTracing.StartParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeTracing.start', callback?: (err: Error | null) => void): void; + /** + * Stop trace events collection. Remaining collected events will be sent as a sequence of + * dataCollected events followed by tracingComplete event. + */ + post(method: 'NodeTracing.stop', callback?: (err: Error | null) => void): void; + /** + * Sends protocol message over session with given id. + */ + post( + method: 'NodeWorker.sendMessageToWorker', + params?: NodeWorker.SendMessageToWorkerParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.sendMessageToWorker', callback?: (err: Error | null) => void): void; + /** + * Instructs the inspector to attach to running workers. Will also attach to new workers + * as they start + */ + post( + method: 'NodeWorker.enable', + params?: NodeWorker.EnableParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.enable', callback?: (err: Error | null) => void): void; + /** + * Detaches from all running workers and disables attaching to new workers as they are started. + */ + post(method: 'NodeWorker.disable', callback?: (err: Error | null) => void): void; + /** + * Detached from the worker with given sessionId. + */ + post( + method: 'NodeWorker.detach', + params?: NodeWorker.DetachParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void; + /** + * Enable the `NodeRuntime.waitingForDisconnect`. + */ + post( + method: 'NodeRuntime.notifyWhenWaitingForDisconnect', + params?: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', callback?: (err: Error | null) => void): void; + // Events + addListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + addListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + addListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + addListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + addListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + addListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + addListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + addListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + addListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + addListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + addListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + addListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + addListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + addListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + addListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + addListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + addListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + addListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + addListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + addListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + addListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + addListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + addListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + addListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + addListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + addListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + addListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + addListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: 'inspectorNotification', message: InspectorNotification<{}>): boolean; + emit( + event: 'Runtime.executionContextCreated', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.executionContextDestroyed', + message: InspectorNotification, + ): boolean; + emit(event: 'Runtime.executionContextsCleared'): boolean; + emit( + event: 'Runtime.exceptionThrown', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.exceptionRevoked', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.consoleAPICalled', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.inspectRequested', + message: InspectorNotification, + ): boolean; + emit(event: 'Debugger.scriptParsed', message: InspectorNotification): boolean; + emit( + event: 'Debugger.scriptFailedToParse', + message: InspectorNotification, + ): boolean; + emit( + event: 'Debugger.breakpointResolved', + message: InspectorNotification, + ): boolean; + emit(event: 'Debugger.paused', message: InspectorNotification): boolean; + emit(event: 'Debugger.resumed'): boolean; + emit(event: 'Console.messageAdded', message: InspectorNotification): boolean; + emit( + event: 'Profiler.consoleProfileStarted', + message: InspectorNotification, + ): boolean; + emit( + event: 'Profiler.consoleProfileFinished', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.addHeapSnapshotChunk', + message: InspectorNotification, + ): boolean; + emit(event: 'HeapProfiler.resetProfiles'): boolean; + emit( + event: 'HeapProfiler.reportHeapSnapshotProgress', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.lastSeenObjectId', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.heapStatsUpdate', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeTracing.dataCollected', + message: InspectorNotification, + ): boolean; + emit(event: 'NodeTracing.tracingComplete'): boolean; + emit( + event: 'NodeWorker.attachedToWorker', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeWorker.detachedFromWorker', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeWorker.receivedMessageFromWorker', + message: InspectorNotification, + ): boolean; + emit(event: 'NodeRuntime.waitingForDisconnect'): boolean; + on(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + on(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + on( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + on( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + on(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + on( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + on( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + on( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + on( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + on( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + on( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + on( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + on( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + on(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + on( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + on( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + on( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + on( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + on(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + on( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + on( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + on( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + on( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + on(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + on( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + on( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + on( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + on(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + once(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + once( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + once( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + once(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + once( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + once( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + once( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + once( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + once( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + once( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + once( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + once( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + once(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + once( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + once( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + once( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + once( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + once(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + once( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + once( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + once( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + once( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + once(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + once( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + once( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + once( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + once(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + prependListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + prependListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + prependListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + prependListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + prependListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + prependListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + prependListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + prependListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependOnceListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependOnceListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + prependOnceListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependOnceListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependOnceListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + prependOnceListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + prependOnceListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependOnceListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependOnceListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependOnceListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependOnceListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependOnceListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependOnceListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependOnceListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependOnceListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependOnceListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependOnceListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependOnceListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + prependOnceListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependOnceListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependOnceListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + prependOnceListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependOnceListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + } + /** + * Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has + * started. + * + * If wait is `true`, will block until a client has connected to the inspect port + * and flow control has been passed to the debugger client. + * + * See the `security warning` regarding the `host`parameter usage. + * @param [port='what was specified on the CLI'] Port to listen on for inspector connections. Optional. + * @param [host='what was specified on the CLI'] Host to listen on for inspector connections. Optional. + * @param [wait=false] Block until a client has connected. Optional. + */ + function open(port?: number, host?: string, wait?: boolean): void; + /** + * Deactivate the inspector. Blocks until there are no active connections. + */ + function close(): void; + /** + * Return the URL of the active inspector, or `undefined` if there is none. + * + * ```console + * $ node --inspect -p 'inspector.url()' + * Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * For help, see: https://nodejs.org/en/docs/inspector + * ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * + * $ node --inspect=localhost:3000 -p 'inspector.url()' + * Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * For help, see: https://nodejs.org/en/docs/inspector + * ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * + * $ node -p 'inspector.url()' + * undefined + * ``` + */ + function url(): string | undefined; + /** + * Blocks until a client (existing or connected later) has sent`Runtime.runIfWaitingForDebugger` command. + * + * An exception will be thrown if there is no active inspector. + * @since v12.7.0 + */ + function waitForDebugger(): void; +} +/** + * The inspector module provides an API for interacting with the V8 inspector. + */ +declare module 'node:inspector' { + import inspector = require('inspector'); + export = inspector; +} diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts new file mode 100644 index 000000000000..f3d8f2cdc0b5 --- /dev/null +++ b/packages/node/src/integrations/localvariables.ts @@ -0,0 +1,135 @@ +import { parseSemver } from '@sentry/utils'; + +const nodeVersion = parseSemver(process.versions.node); + +if ((nodeVersion.major || 0) < 14) { + throw new Error('LocalVariables integration requires node.js >=v14'); +} + +import { Event, EventProcessor } from '@sentry/types'; +import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; + +/** + * Promise API is available as `Experimental` and in Node 19 only. + * + * Callback-based API is `Stable` since v14 and `Experimental` since v8. + * Because of that, we are creating our own `AsyncSession` class. + * + * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api + * https://nodejs.org/docs/latest-v14.x/api/inspector.html + */ +class AsyncSession extends Session { + public async getProperties(objectId: string): Promise { + return new Promise((resolve, reject) => { + this.post( + 'Runtime.getProperties', + { + objectId, + ownProperties: true, + }, + (err, params) => { + if (err) { + reject(err); + } else { + resolve(params.result); + } + }, + ); + }); + } +} + +/** */ +export class LocalVariables { + public static id: string = 'LocalVariables'; + + public name: string = LocalVariables.id; + + private readonly _session: AsyncSession; + + private _props: Record | undefined; + + public constructor() { + this._session = new AsyncSession(); + this._session.connect(); + this._session.on('Debugger.paused', this._handlePaused.bind(this)); + this._session.post('Debugger.enable'); + this._session.post('Debugger.setPauseOnExceptions', { state: 'all' }); + } + + /** + * @inheritDoc + */ + public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void { + addGlobalEventProcessor(async event => this._addLocalVariables(event)); + } + + /** */ + private async _handlePaused(event: InspectorNotification): Promise { + // TODO: Exceptions only for now + // TODO: Handle all frames + if (event.params.reason == 'exception') { + const topFrame = event.params.callFrames[0]; + const localScope = topFrame.scopeChain.find(scope => scope.type === 'local'); + + if (localScope?.object?.objectId) { + this._props = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); + // eslint-disable-next-line no-console + console.log(this._props); + } + } + } + + /** */ + private async _unrollProps(props: Runtime.PropertyDescriptor[]): Promise> { + const unrolled: Record = {}; + + for (const prop of props) { + if (prop?.value?.objectId && prop?.value.className === 'Array') { + unrolled[prop.name] = await this._unrollArray(prop.value.objectId); + } else if (prop?.value?.objectId && prop?.value?.className === 'Object') { + unrolled[prop.name] = await this._unrollObject(prop.value.objectId); + } else if (prop?.value?.value || prop?.value?.description) { + unrolled[prop.name] = prop.value.value || `<${prop.value.description}>`; + } + } + + return unrolled; + } + + /** */ + private async _unrollArray(objectId: string): Promise { + const props = await this._session.getProperties(objectId); + return props + .filter(v => v.name !== 'length') + .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) + .map(v => v?.value?.value); + } + + /** */ + private async _unrollObject(objectId: string): Promise> { + const props = await this._session.getProperties(objectId); + return props + .map<[string, unknown]>(v => [v.name, v?.value?.value]) + .reduce((obj, [key, val]) => { + obj[key] = val; + return obj; + }, {} as Record); + } + + // TODO: This is not 100% safe, as we cannot assume it will be _this_ exception from debugger + // we will need to keep a LRU-cache or similar in order to make it reliable. + // TODO: Handle all frames + /** */ + private async _addLocalVariables(event: Event): Promise { + if (event?.exception?.values?.[0]?.stacktrace?.frames) { + event.exception.values[0].stacktrace.frames.reverse()[0].vars = { + ...this._props, + }; + + this._props = undefined; + } + + return event; + } +} diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index 42751525fbaa..b0a60d147fdb 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -13,6 +13,7 @@ import { GLOBAL_OBJ, logger, nodeStackLineParser, + parseSemver, stackParserFromStackParserOptions, } from '@sentry/utils'; import * as domain from 'domain'; @@ -107,6 +108,7 @@ export const defaultIntegrations = [ * * @see {@link NodeOptions} for documentation on configuration options. */ +// eslint-disable-next-line complexity export function init(options: NodeOptions = {}): void { const carrier = getMainCarrier(); const autoloadedIntegrations = carrier.__SENTRY__?.integrations || []; @@ -119,6 +121,14 @@ export function init(options: NodeOptions = {}): void { ...autoloadedIntegrations, ]; + const nodeVersion = parseSemver(process.versions.node); + + if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { LocalVariables } = require('./integrations/localvariables'); + options.defaultIntegrations.push(new LocalVariables()); + } + if (options.dsn === undefined && process.env.SENTRY_DSN) { options.dsn = process.env.SENTRY_DSN; } diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index d4ca5dd4900d..5dd9f16cddfe 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -11,6 +11,9 @@ export interface BaseNodeOptions { /** Sets an optional server name (device name) */ serverName?: string; + /** */ + includeStackLocals?: boolean; + // TODO (v8): Remove this in v8 /** * @deprecated Moved to constructor options of the `Http` integration. From 47bf3531053a3b0ca9c772f8cfb1479a497dad49 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 7 Dec 2022 21:19:14 +0000 Subject: [PATCH 02/19] Add LocalVariables integration --- packages/node/src/integrations/inspector.d.ts | 3359 +++++++++++++++++ .../node/src/integrations/localvariables.ts | 226 ++ packages/node/src/sdk.ts | 10 + packages/node/src/types.ts | 3 + 4 files changed, 3598 insertions(+) create mode 100644 packages/node/src/integrations/inspector.d.ts create mode 100644 packages/node/src/integrations/localvariables.ts diff --git a/packages/node/src/integrations/inspector.d.ts b/packages/node/src/integrations/inspector.d.ts new file mode 100644 index 000000000000..8128d2ad14f7 --- /dev/null +++ b/packages/node/src/integrations/inspector.d.ts @@ -0,0 +1,3359 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/unified-signatures */ +/* eslint-disable @typescript-eslint/explicit-member-accessibility */ +/* eslint-disable max-lines */ +/* eslint-disable @typescript-eslint/ban-types */ +// Type definitions for inspector + +// These definitions were copied from: +// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d37bf642ed2f3fe403e405892e2eb4240a191bb0/types/node/inspector.d.ts + +/** + * The `inspector` module provides an API for interacting with the V8 inspector. + * + * It can be accessed using: + * + * ```js + * const inspector = require('inspector'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js) + */ +declare module 'inspector' { + import EventEmitter = require('node:events'); + interface InspectorNotification { + method: string; + params: T; + } + namespace Schema { + /** + * Description of the protocol domain. + */ + interface Domain { + /** + * Domain name. + */ + name: string; + /** + * Domain version. + */ + version: string; + } + interface GetDomainsReturnType { + /** + * List of supported domains. + */ + domains: Domain[]; + } + } + namespace Runtime { + /** + * Unique script identifier. + */ + type ScriptId = string; + /** + * Unique object identifier. + */ + type RemoteObjectId = string; + /** + * Primitive value which cannot be JSON-stringified. + */ + type UnserializableValue = string; + /** + * Mirror object referencing original JavaScript object. + */ + interface RemoteObject { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * Object class (constructor) name. Specified for object type values only. + */ + className?: string | undefined; + /** + * Remote object value in case of primitive values or JSON values (if it was requested). + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified does not have value, but gets this property. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * Unique object identifier (for non-primitive values). + */ + objectId?: RemoteObjectId | undefined; + /** + * Preview containing abbreviated property values. Specified for object type values only. + * @experimental + */ + preview?: ObjectPreview | undefined; + /** + * @experimental + */ + customPreview?: CustomPreview | undefined; + } + /** + * @experimental + */ + interface CustomPreview { + header: string; + hasBody: boolean; + formatterObjectId: RemoteObjectId; + bindRemoteObjectFunctionId: RemoteObjectId; + configObjectId?: RemoteObjectId | undefined; + } + /** + * Object containing abbreviated remote object value. + * @experimental + */ + interface ObjectPreview { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * True iff some of the properties or entries of the original object did not fit. + */ + overflow: boolean; + /** + * List of the properties. + */ + properties: PropertyPreview[]; + /** + * List of the entries. Specified for map and set subtype values only. + */ + entries?: EntryPreview[] | undefined; + } + /** + * @experimental + */ + interface PropertyPreview { + /** + * Property name. + */ + name: string; + /** + * Object type. Accessor means that the property itself is an accessor property. + */ + type: string; + /** + * User-friendly property value string. + */ + value?: string | undefined; + /** + * Nested value preview. + */ + valuePreview?: ObjectPreview | undefined; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + } + /** + * @experimental + */ + interface EntryPreview { + /** + * Preview of the key. Specified for map-like collection entries. + */ + key?: ObjectPreview | undefined; + /** + * Preview of the value. + */ + value: ObjectPreview; + } + /** + * Object property descriptor. + */ + interface PropertyDescriptor { + /** + * Property name or symbol description. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + /** + * True if the value associated with the property may be changed (data descriptors only). + */ + writable?: boolean | undefined; + /** + * A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only). + */ + get?: RemoteObject | undefined; + /** + * A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only). + */ + set?: RemoteObject | undefined; + /** + * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. + */ + configurable: boolean; + /** + * True if this property shows up during enumeration of the properties on the corresponding object. + */ + enumerable: boolean; + /** + * True if the result was thrown during the evaluation. + */ + wasThrown?: boolean | undefined; + /** + * True if the property is owned for the object. + */ + isOwn?: boolean | undefined; + /** + * Property symbol object, if the property is of the symbol type. + */ + symbol?: RemoteObject | undefined; + } + /** + * Object internal property descriptor. This property isn't normally visible in JavaScript code. + */ + interface InternalPropertyDescriptor { + /** + * Conventional property name. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + } + /** + * Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified. + */ + interface CallArgument { + /** + * Primitive value or serializable javascript object. + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * Remote object handle. + */ + objectId?: RemoteObjectId | undefined; + } + /** + * Id of an execution context. + */ + type ExecutionContextId = number; + /** + * Description of an isolated world. + */ + interface ExecutionContextDescription { + /** + * Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed. + */ + id: ExecutionContextId; + /** + * Execution context origin. + */ + origin: string; + /** + * Human readable name describing given context. + */ + name: string; + /** + * Embedder-specific auxiliary data. + */ + auxData?: {} | undefined; + } + /** + * Detailed information about exception (or error) that was thrown during script compilation or execution. + */ + interface ExceptionDetails { + /** + * Exception id. + */ + exceptionId: number; + /** + * Exception text, which should be used together with exception object when available. + */ + text: string; + /** + * Line number of the exception location (0-based). + */ + lineNumber: number; + /** + * Column number of the exception location (0-based). + */ + columnNumber: number; + /** + * Script ID of the exception location. + */ + scriptId?: ScriptId | undefined; + /** + * URL of the exception location, to be used when the script was not reported. + */ + url?: string | undefined; + /** + * JavaScript stack trace if available. + */ + stackTrace?: StackTrace | undefined; + /** + * Exception object if available. + */ + exception?: RemoteObject | undefined; + /** + * Identifier of the context where exception happened. + */ + executionContextId?: ExecutionContextId | undefined; + } + /** + * Number of milliseconds since epoch. + */ + type Timestamp = number; + /** + * Stack entry for runtime errors and assertions. + */ + interface CallFrame { + /** + * JavaScript function name. + */ + functionName: string; + /** + * JavaScript script id. + */ + scriptId: ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * JavaScript script line number (0-based). + */ + lineNumber: number; + /** + * JavaScript script column number (0-based). + */ + columnNumber: number; + } + /** + * Call frames for assertions or error messages. + */ + interface StackTrace { + /** + * String label of this stack trace. For async traces this may be a name of the function that initiated the async call. + */ + description?: string | undefined; + /** + * JavaScript function name. + */ + callFrames: CallFrame[]; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + */ + parent?: StackTrace | undefined; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + * @experimental + */ + parentId?: StackTraceId | undefined; + } + /** + * Unique identifier of current debugger. + * @experimental + */ + type UniqueDebuggerId = string; + /** + * If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages. + * @experimental + */ + interface StackTraceId { + id: string; + debuggerId?: UniqueDebuggerId | undefined; + } + interface EvaluateParameterType { + /** + * Expression to evaluate. + */ + expression: string; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + contextId?: ExecutionContextId | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface AwaitPromiseParameterType { + /** + * Identifier of the promise. + */ + promiseObjectId: RemoteObjectId; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + } + interface CallFunctionOnParameterType { + /** + * Declaration of the function to call. + */ + functionDeclaration: string; + /** + * Identifier of the object to call function on. Either objectId or executionContextId should be specified. + */ + objectId?: RemoteObjectId | undefined; + /** + * Call arguments. All call arguments must belong to the same JavaScript world as the target object. + */ + arguments?: CallArgument[] | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + /** + * Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object. + */ + objectGroup?: string | undefined; + } + interface GetPropertiesParameterType { + /** + * Identifier of the object to return properties for. + */ + objectId: RemoteObjectId; + /** + * If true, returns properties belonging only to the element itself, not to its prototype chain. + */ + ownProperties?: boolean | undefined; + /** + * If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. + * @experimental + */ + accessorPropertiesOnly?: boolean | undefined; + /** + * Whether preview should be generated for the results. + * @experimental + */ + generatePreview?: boolean | undefined; + } + interface ReleaseObjectParameterType { + /** + * Identifier of the object to release. + */ + objectId: RemoteObjectId; + } + interface ReleaseObjectGroupParameterType { + /** + * Symbolic object group name. + */ + objectGroup: string; + } + interface SetCustomObjectFormatterEnabledParameterType { + enabled: boolean; + } + interface CompileScriptParameterType { + /** + * Expression to compile. + */ + expression: string; + /** + * Source url to be set for the script. + */ + sourceURL: string; + /** + * Specifies whether the compiled script should be persisted. + */ + persistScript: boolean; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface RunScriptParameterType { + /** + * Id of the script to run. + */ + scriptId: ScriptId; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface QueryObjectsParameterType { + /** + * Identifier of the prototype to return objects for. + */ + prototypeObjectId: RemoteObjectId; + } + interface GlobalLexicalScopeNamesParameterType { + /** + * Specifies in which execution context to lookup global scope variables. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface EvaluateReturnType { + /** + * Evaluation result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface AwaitPromiseReturnType { + /** + * Promise result. Will contain rejected value if promise was rejected. + */ + result: RemoteObject; + /** + * Exception details if stack strace is available. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CallFunctionOnReturnType { + /** + * Call result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface GetPropertiesReturnType { + /** + * Object properties. + */ + result: PropertyDescriptor[]; + /** + * Internal object properties (only of the element itself). + */ + internalProperties?: InternalPropertyDescriptor[] | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CompileScriptReturnType { + /** + * Id of the script. + */ + scriptId?: ScriptId | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface RunScriptReturnType { + /** + * Run result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface QueryObjectsReturnType { + /** + * Array with objects. + */ + objects: RemoteObject; + } + interface GlobalLexicalScopeNamesReturnType { + names: string[]; + } + interface ExecutionContextCreatedEventDataType { + /** + * A newly created execution context. + */ + context: ExecutionContextDescription; + } + interface ExecutionContextDestroyedEventDataType { + /** + * Id of the destroyed context + */ + executionContextId: ExecutionContextId; + } + interface ExceptionThrownEventDataType { + /** + * Timestamp of the exception. + */ + timestamp: Timestamp; + exceptionDetails: ExceptionDetails; + } + interface ExceptionRevokedEventDataType { + /** + * Reason describing why exception was revoked. + */ + reason: string; + /** + * The id of revoked exception, as reported in exceptionThrown. + */ + exceptionId: number; + } + interface ConsoleAPICalledEventDataType { + /** + * Type of the call. + */ + type: string; + /** + * Call arguments. + */ + args: RemoteObject[]; + /** + * Identifier of the context where the call was made. + */ + executionContextId: ExecutionContextId; + /** + * Call timestamp. + */ + timestamp: Timestamp; + /** + * Stack trace captured when the call was made. + */ + stackTrace?: StackTrace | undefined; + /** + * Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context. + * @experimental + */ + context?: string | undefined; + } + interface InspectRequestedEventDataType { + object: RemoteObject; + hints: {}; + } + } + namespace Debugger { + /** + * Breakpoint identifier. + */ + type BreakpointId = string; + /** + * Call frame identifier. + */ + type CallFrameId = string; + /** + * Location in the source code. + */ + interface Location { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + } + /** + * Location in the source code. + * @experimental + */ + interface ScriptPosition { + lineNumber: number; + columnNumber: number; + } + /** + * JavaScript call frame. Array of call frames form the call stack. + */ + interface CallFrame { + /** + * Call frame identifier. This identifier is only valid while the virtual machine is paused. + */ + callFrameId: CallFrameId; + /** + * Name of the JavaScript function called on this call frame. + */ + functionName: string; + /** + * Location in the source code. + */ + functionLocation?: Location | undefined; + /** + * Location in the source code. + */ + location: Location; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Scope chain for this call frame. + */ + scopeChain: Scope[]; + /** + * this object for this call frame. + */ + this: Runtime.RemoteObject; + /** + * The value being returned, if the function is at return point. + */ + returnValue?: Runtime.RemoteObject | undefined; + } + /** + * Scope description. + */ + interface Scope { + /** + * Scope type. + */ + type: string; + /** + * Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties. + */ + object: Runtime.RemoteObject; + name?: string | undefined; + /** + * Location in the source code where scope starts + */ + startLocation?: Location | undefined; + /** + * Location in the source code where scope ends + */ + endLocation?: Location | undefined; + } + /** + * Search match for resource. + */ + interface SearchMatch { + /** + * Line number in resource content. + */ + lineNumber: number; + /** + * Line with match content. + */ + lineContent: string; + } + interface BreakLocation { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + type?: string | undefined; + } + interface SetBreakpointsActiveParameterType { + /** + * New value for breakpoints active state. + */ + active: boolean; + } + interface SetSkipAllPausesParameterType { + /** + * New value for skip pauses state. + */ + skip: boolean; + } + interface SetBreakpointByUrlParameterType { + /** + * Line number to set breakpoint at. + */ + lineNumber: number; + /** + * URL of the resources to set breakpoint on. + */ + url?: string | undefined; + /** + * Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. + */ + urlRegex?: string | undefined; + /** + * Script hash of the resources to set breakpoint on. + */ + scriptHash?: string | undefined; + /** + * Offset in the line to set breakpoint at. + */ + columnNumber?: number | undefined; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface SetBreakpointParameterType { + /** + * Location to set breakpoint in. + */ + location: Location; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface RemoveBreakpointParameterType { + breakpointId: BreakpointId; + } + interface GetPossibleBreakpointsParameterType { + /** + * Start of range to search possible breakpoint locations in. + */ + start: Location; + /** + * End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. + */ + end?: Location | undefined; + /** + * Only consider locations which are in the same (non-nested) function as start. + */ + restrictToFunction?: boolean | undefined; + } + interface ContinueToLocationParameterType { + /** + * Location to continue to. + */ + location: Location; + targetCallFrames?: string | undefined; + } + interface PauseOnAsyncCallParameterType { + /** + * Debugger will pause when async call with given stack trace is started. + */ + parentStackTraceId: Runtime.StackTraceId; + } + interface StepIntoParameterType { + /** + * Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. + * @experimental + */ + breakOnAsyncCall?: boolean | undefined; + } + interface GetStackTraceParameterType { + stackTraceId: Runtime.StackTraceId; + } + interface SearchInContentParameterType { + /** + * Id of the script to search in. + */ + scriptId: Runtime.ScriptId; + /** + * String to search for. + */ + query: string; + /** + * If true, search is case sensitive. + */ + caseSensitive?: boolean | undefined; + /** + * If true, treats string parameter as regex. + */ + isRegex?: boolean | undefined; + } + interface SetScriptSourceParameterType { + /** + * Id of the script to edit. + */ + scriptId: Runtime.ScriptId; + /** + * New content of the script. + */ + scriptSource: string; + /** + * If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. + */ + dryRun?: boolean | undefined; + } + interface RestartFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + } + interface GetScriptSourceParameterType { + /** + * Id of the script to get source for. + */ + scriptId: Runtime.ScriptId; + } + interface SetPauseOnExceptionsParameterType { + /** + * Pause on exceptions mode. + */ + state: string; + } + interface EvaluateOnCallFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + /** + * Expression to evaluate. + */ + expression: string; + /** + * String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup). + */ + objectGroup?: string | undefined; + /** + * Specifies whether command line API should be available to the evaluated expression, defaults to false. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether to throw an exception if side effect cannot be ruled out during evaluation. + */ + throwOnSideEffect?: boolean | undefined; + } + interface SetVariableValueParameterType { + /** + * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. + */ + scopeNumber: number; + /** + * Variable name. + */ + variableName: string; + /** + * New variable value. + */ + newValue: Runtime.CallArgument; + /** + * Id of callframe that holds variable. + */ + callFrameId: CallFrameId; + } + interface SetReturnValueParameterType { + /** + * New return value. + */ + newValue: Runtime.CallArgument; + } + interface SetAsyncCallStackDepthParameterType { + /** + * Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default). + */ + maxDepth: number; + } + interface SetBlackboxPatternsParameterType { + /** + * Array of regexps that will be used to check script url for blackbox state. + */ + patterns: string[]; + } + interface SetBlackboxedRangesParameterType { + /** + * Id of the script. + */ + scriptId: Runtime.ScriptId; + positions: ScriptPosition[]; + } + interface EnableReturnType { + /** + * Unique identifier of the debugger. + * @experimental + */ + debuggerId: Runtime.UniqueDebuggerId; + } + interface SetBreakpointByUrlReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * List of the locations this breakpoint resolved into upon addition. + */ + locations: Location[]; + } + interface SetBreakpointReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * Location this breakpoint resolved into. + */ + actualLocation: Location; + } + interface GetPossibleBreakpointsReturnType { + /** + * List of the possible breakpoint locations. + */ + locations: BreakLocation[]; + } + interface GetStackTraceReturnType { + stackTrace: Runtime.StackTrace; + } + interface SearchInContentReturnType { + /** + * List of search matches. + */ + result: SearchMatch[]; + } + interface SetScriptSourceReturnType { + /** + * New stack trace in case editing has happened while VM was stopped. + */ + callFrames?: CallFrame[] | undefined; + /** + * Whether current call stack was modified after applying the changes. + */ + stackChanged?: boolean | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Exception details if any. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface RestartFrameReturnType { + /** + * New stack trace. + */ + callFrames: CallFrame[]; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + } + interface GetScriptSourceReturnType { + /** + * Script source. + */ + scriptSource: string; + } + interface EvaluateOnCallFrameReturnType { + /** + * Object wrapper for the evaluation result. + */ + result: Runtime.RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface ScriptParsedEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * True, if this script is generated as a result of the live edit operation. + * @experimental + */ + isLiveEdit?: boolean | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface ScriptFailedToParseEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface BreakpointResolvedEventDataType { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } + interface PausedEventDataType { + /** + * Call stack the virtual machine stopped on. + */ + callFrames: CallFrame[]; + /** + * Pause reason. + */ + reason: string; + /** + * Object containing break-specific auxiliary properties. + */ + data?: {} | undefined; + /** + * Hit breakpoints IDs + */ + hitBreakpoints?: string[] | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag. + * @experimental + */ + asyncCallStackTraceId?: Runtime.StackTraceId | undefined; + } + } + namespace Console { + /** + * Console message. + */ + interface ConsoleMessage { + /** + * Message source. + */ + source: string; + /** + * Message severity. + */ + level: string; + /** + * Message text. + */ + text: string; + /** + * URL of the message origin. + */ + url?: string | undefined; + /** + * Line number in the resource that generated this message (1-based). + */ + line?: number | undefined; + /** + * Column number in the resource that generated this message (1-based). + */ + column?: number | undefined; + } + interface MessageAddedEventDataType { + /** + * Console message that has been added. + */ + message: ConsoleMessage; + } + } + namespace Profiler { + /** + * Profile node. Holds callsite information, execution statistics and child nodes. + */ + interface ProfileNode { + /** + * Unique id of the node. + */ + id: number; + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Number of samples where this node was on top of the call stack. + */ + hitCount?: number | undefined; + /** + * Child node ids. + */ + children?: number[] | undefined; + /** + * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. + */ + deoptReason?: string | undefined; + /** + * An array of source position ticks. + */ + positionTicks?: PositionTickInfo[] | undefined; + } + /** + * Profile. + */ + interface Profile { + /** + * The list of profile nodes. First item is the root node. + */ + nodes: ProfileNode[]; + /** + * Profiling start timestamp in microseconds. + */ + startTime: number; + /** + * Profiling end timestamp in microseconds. + */ + endTime: number; + /** + * Ids of samples top nodes. + */ + samples?: number[] | undefined; + /** + * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. + */ + timeDeltas?: number[] | undefined; + } + /** + * Specifies a number of samples attributed to a certain source position. + */ + interface PositionTickInfo { + /** + * Source line number (1-based). + */ + line: number; + /** + * Number of samples attributed to the source line. + */ + ticks: number; + } + /** + * Coverage data for a source range. + */ + interface CoverageRange { + /** + * JavaScript script source offset for the range start. + */ + startOffset: number; + /** + * JavaScript script source offset for the range end. + */ + endOffset: number; + /** + * Collected execution count of the source range. + */ + count: number; + } + /** + * Coverage data for a JavaScript function. + */ + interface FunctionCoverage { + /** + * JavaScript function name. + */ + functionName: string; + /** + * Source ranges inside the function with coverage data. + */ + ranges: CoverageRange[]; + /** + * Whether coverage data for this function has block granularity. + */ + isBlockCoverage: boolean; + } + /** + * Coverage data for a JavaScript script. + */ + interface ScriptCoverage { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Functions contained in the script that has coverage data. + */ + functions: FunctionCoverage[]; + } + /** + * Describes a type collected during runtime. + * @experimental + */ + interface TypeObject { + /** + * Name of a type collected with type profiling. + */ + name: string; + } + /** + * Source offset and types for a parameter or return value. + * @experimental + */ + interface TypeProfileEntry { + /** + * Source offset of the parameter or end of function for return values. + */ + offset: number; + /** + * The types for this parameter or return value. + */ + types: TypeObject[]; + } + /** + * Type profile data collected during runtime for a JavaScript script. + * @experimental + */ + interface ScriptTypeProfile { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Type profile entries for parameters and return values of the functions in the script. + */ + entries: TypeProfileEntry[]; + } + interface SetSamplingIntervalParameterType { + /** + * New sampling interval in microseconds. + */ + interval: number; + } + interface StartPreciseCoverageParameterType { + /** + * Collect accurate call counts beyond simple 'covered' or 'not covered'. + */ + callCount?: boolean | undefined; + /** + * Collect block-based coverage. + */ + detailed?: boolean | undefined; + } + interface StopReturnType { + /** + * Recorded profile. + */ + profile: Profile; + } + interface TakePreciseCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface GetBestEffortCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface TakeTypeProfileReturnType { + /** + * Type profile for all scripts since startTypeProfile() was turned on. + */ + result: ScriptTypeProfile[]; + } + interface ConsoleProfileStartedEventDataType { + id: string; + /** + * Location of console.profile(). + */ + location: Debugger.Location; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + interface ConsoleProfileFinishedEventDataType { + id: string; + /** + * Location of console.profileEnd(). + */ + location: Debugger.Location; + profile: Profile; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + } + namespace HeapProfiler { + /** + * Heap snapshot object id. + */ + type HeapSnapshotObjectId = string; + /** + * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. + */ + interface SamplingHeapProfileNode { + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Allocations size in bytes for the node excluding children. + */ + selfSize: number; + /** + * Child nodes. + */ + children: SamplingHeapProfileNode[]; + } + /** + * Profile. + */ + interface SamplingHeapProfile { + head: SamplingHeapProfileNode; + } + interface StartTrackingHeapObjectsParameterType { + trackAllocations?: boolean | undefined; + } + interface StopTrackingHeapObjectsParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. + */ + reportProgress?: boolean | undefined; + } + interface TakeHeapSnapshotParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. + */ + reportProgress?: boolean | undefined; + } + interface GetObjectByHeapObjectIdParameterType { + objectId: HeapSnapshotObjectId; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + } + interface AddInspectedHeapObjectParameterType { + /** + * Heap snapshot object id to be accessible by means of $x command line API. + */ + heapObjectId: HeapSnapshotObjectId; + } + interface GetHeapObjectIdParameterType { + /** + * Identifier of the object to get heap object id for. + */ + objectId: Runtime.RemoteObjectId; + } + interface StartSamplingParameterType { + /** + * Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. + */ + samplingInterval?: number | undefined; + } + interface GetObjectByHeapObjectIdReturnType { + /** + * Evaluation result. + */ + result: Runtime.RemoteObject; + } + interface GetHeapObjectIdReturnType { + /** + * Id of the heap snapshot object corresponding to the passed remote object id. + */ + heapSnapshotObjectId: HeapSnapshotObjectId; + } + interface StopSamplingReturnType { + /** + * Recorded sampling heap profile. + */ + profile: SamplingHeapProfile; + } + interface GetSamplingProfileReturnType { + /** + * Return the sampling profile being collected. + */ + profile: SamplingHeapProfile; + } + interface AddHeapSnapshotChunkEventDataType { + chunk: string; + } + interface ReportHeapSnapshotProgressEventDataType { + done: number; + total: number; + finished?: boolean | undefined; + } + interface LastSeenObjectIdEventDataType { + lastSeenObjectId: number; + timestamp: number; + } + interface HeapStatsUpdateEventDataType { + /** + * An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. + */ + statsUpdate: number[]; + } + } + namespace NodeTracing { + interface TraceConfig { + /** + * Controls how the trace buffer stores data. + */ + recordMode?: string | undefined; + /** + * Included category filters. + */ + includedCategories: string[]; + } + interface StartParameterType { + traceConfig: TraceConfig; + } + interface GetCategoriesReturnType { + /** + * A list of supported tracing categories. + */ + categories: string[]; + } + interface DataCollectedEventDataType { + value: Array<{}>; + } + } + namespace NodeWorker { + type WorkerID = string; + /** + * Unique identifier of attached debugging session. + */ + type SessionID = string; + interface WorkerInfo { + workerId: WorkerID; + type: string; + title: string; + url: string; + } + interface SendMessageToWorkerParameterType { + message: string; + /** + * Identifier of the session. + */ + sessionId: SessionID; + } + interface EnableParameterType { + /** + * Whether to new workers should be paused until the frontend sends `Runtime.runIfWaitingForDebugger` + * message to run them. + */ + waitForDebuggerOnStart: boolean; + } + interface DetachParameterType { + sessionId: SessionID; + } + interface AttachedToWorkerEventDataType { + /** + * Identifier assigned to the session used to send/receive messages. + */ + sessionId: SessionID; + workerInfo: WorkerInfo; + waitingForDebugger: boolean; + } + interface DetachedFromWorkerEventDataType { + /** + * Detached session identifier. + */ + sessionId: SessionID; + } + interface ReceivedMessageFromWorkerEventDataType { + /** + * Identifier of a session which sends a message. + */ + sessionId: SessionID; + message: string; + } + } + namespace NodeRuntime { + interface NotifyWhenWaitingForDisconnectParameterType { + enabled: boolean; + } + } + /** + * The `inspector.Session` is used for dispatching messages to the V8 inspector + * back-end and receiving message responses and notifications. + */ + class Session extends EventEmitter { + /** + * Create a new instance of the inspector.Session class. + * The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend. + */ + constructor(); + /** + * Connects a session to the inspector back-end. + * @since v8.0.0 + */ + connect(): void; + /** + * Immediately close the session. All pending message callbacks will be called + * with an error. `session.connect()` will need to be called to be able to send + * messages again. Reconnected session will lose all inspector state, such as + * enabled agents or configured breakpoints. + * @since v8.0.0 + */ + disconnect(): void; + /** + * Posts a message to the inspector back-end. `callback` will be notified when + * a response is received. `callback` is a function that accepts two optional + * arguments: error and message-specific result. + * + * ```js + * session.post('Runtime.evaluate', { expression: '2 + 2' }, + * (error, { result }) => console.log(result)); + * // Output: { type: 'number', value: 4, description: '4' } + * ``` + * + * The latest version of the V8 inspector protocol is published on the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/v8/). + * + * Node.js inspector supports all the Chrome DevTools Protocol domains declared + * by V8\. Chrome DevTools Protocol domain provides an interface for interacting + * with one of the runtime agents used to inspect the application state and listen + * to the run-time events. + * + * ## Example usage + * + * Apart from the debugger, various V8 Profilers are available through the DevTools + * protocol. + * @since v8.0.0 + */ + post(method: string, params?: {}, callback?: (err: Error | null, params?: {}) => void): void; + post(method: string, callback?: (err: Error | null, params?: {}) => void): void; + /** + * Returns supported domains. + */ + post( + method: 'Schema.getDomains', + callback?: (err: Error | null, params: Schema.GetDomainsReturnType) => void, + ): void; + /** + * Evaluates expression on global object. + */ + post( + method: 'Runtime.evaluate', + params?: Runtime.EvaluateParameterType, + callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void, + ): void; + post(method: 'Runtime.evaluate', callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + /** + * Add handler to promise with given promise object id. + */ + post( + method: 'Runtime.awaitPromise', + params?: Runtime.AwaitPromiseParameterType, + callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, + ): void; + post( + method: 'Runtime.awaitPromise', + callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, + ): void; + /** + * Calls function with given declaration on the given object. Object group of the result is inherited from the target object. + */ + post( + method: 'Runtime.callFunctionOn', + params?: Runtime.CallFunctionOnParameterType, + callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, + ): void; + post( + method: 'Runtime.callFunctionOn', + callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, + ): void; + /** + * Returns properties of a given object. Object group of the result is inherited from the target object. + */ + post( + method: 'Runtime.getProperties', + params?: Runtime.GetPropertiesParameterType, + callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, + ): void; + post( + method: 'Runtime.getProperties', + callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, + ): void; + /** + * Releases remote object with given id. + */ + post( + method: 'Runtime.releaseObject', + params?: Runtime.ReleaseObjectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.releaseObject', callback?: (err: Error | null) => void): void; + /** + * Releases all remote objects that belong to a given group. + */ + post( + method: 'Runtime.releaseObjectGroup', + params?: Runtime.ReleaseObjectGroupParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.releaseObjectGroup', callback?: (err: Error | null) => void): void; + /** + * Tells inspected instance to run if it was waiting for debugger to attach. + */ + post(method: 'Runtime.runIfWaitingForDebugger', callback?: (err: Error | null) => void): void; + /** + * Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context. + */ + post(method: 'Runtime.enable', callback?: (err: Error | null) => void): void; + /** + * Disables reporting of execution contexts creation. + */ + post(method: 'Runtime.disable', callback?: (err: Error | null) => void): void; + /** + * Discards collected exceptions and console API calls. + */ + post(method: 'Runtime.discardConsoleEntries', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post( + method: 'Runtime.setCustomObjectFormatterEnabled', + params?: Runtime.SetCustomObjectFormatterEnabledParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.setCustomObjectFormatterEnabled', callback?: (err: Error | null) => void): void; + /** + * Compiles expression. + */ + post( + method: 'Runtime.compileScript', + params?: Runtime.CompileScriptParameterType, + callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, + ): void; + post( + method: 'Runtime.compileScript', + callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, + ): void; + /** + * Runs script with given id in a given context. + */ + post( + method: 'Runtime.runScript', + params?: Runtime.RunScriptParameterType, + callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, + ): void; + post( + method: 'Runtime.runScript', + callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, + ): void; + post( + method: 'Runtime.queryObjects', + params?: Runtime.QueryObjectsParameterType, + callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, + ): void; + post( + method: 'Runtime.queryObjects', + callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, + ): void; + /** + * Returns all let, const and class variables from global scope. + */ + post( + method: 'Runtime.globalLexicalScopeNames', + params?: Runtime.GlobalLexicalScopeNamesParameterType, + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, + ): void; + post( + method: 'Runtime.globalLexicalScopeNames', + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, + ): void; + /** + * Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received. + */ + post(method: 'Debugger.enable', callback?: (err: Error | null, params: Debugger.EnableReturnType) => void): void; + /** + * Disables debugger for given page. + */ + post(method: 'Debugger.disable', callback?: (err: Error | null) => void): void; + /** + * Activates / deactivates all breakpoints on the page. + */ + post( + method: 'Debugger.setBreakpointsActive', + params?: Debugger.SetBreakpointsActiveParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBreakpointsActive', callback?: (err: Error | null) => void): void; + /** + * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + */ + post( + method: 'Debugger.setSkipAllPauses', + params?: Debugger.SetSkipAllPausesParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setSkipAllPauses', callback?: (err: Error | null) => void): void; + /** + * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads. + */ + post( + method: 'Debugger.setBreakpointByUrl', + params?: Debugger.SetBreakpointByUrlParameterType, + callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, + ): void; + post( + method: 'Debugger.setBreakpointByUrl', + callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, + ): void; + /** + * Sets JavaScript breakpoint at a given location. + */ + post( + method: 'Debugger.setBreakpoint', + params?: Debugger.SetBreakpointParameterType, + callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, + ): void; + post( + method: 'Debugger.setBreakpoint', + callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, + ): void; + /** + * Removes JavaScript breakpoint. + */ + post( + method: 'Debugger.removeBreakpoint', + params?: Debugger.RemoveBreakpointParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.removeBreakpoint', callback?: (err: Error | null) => void): void; + /** + * Returns possible locations for breakpoint. scriptId in start and end range locations should be the same. + */ + post( + method: 'Debugger.getPossibleBreakpoints', + params?: Debugger.GetPossibleBreakpointsParameterType, + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, + ): void; + post( + method: 'Debugger.getPossibleBreakpoints', + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, + ): void; + /** + * Continues execution until specific location is reached. + */ + post( + method: 'Debugger.continueToLocation', + params?: Debugger.ContinueToLocationParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.continueToLocation', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post( + method: 'Debugger.pauseOnAsyncCall', + params?: Debugger.PauseOnAsyncCallParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.pauseOnAsyncCall', callback?: (err: Error | null) => void): void; + /** + * Steps over the statement. + */ + post(method: 'Debugger.stepOver', callback?: (err: Error | null) => void): void; + /** + * Steps into the function call. + */ + post( + method: 'Debugger.stepInto', + params?: Debugger.StepIntoParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.stepInto', callback?: (err: Error | null) => void): void; + /** + * Steps out of the function call. + */ + post(method: 'Debugger.stepOut', callback?: (err: Error | null) => void): void; + /** + * Stops on the next JavaScript statement. + */ + post(method: 'Debugger.pause', callback?: (err: Error | null) => void): void; + /** + * This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called. + * @experimental + */ + post(method: 'Debugger.scheduleStepIntoAsync', callback?: (err: Error | null) => void): void; + /** + * Resumes JavaScript execution. + */ + post(method: 'Debugger.resume', callback?: (err: Error | null) => void): void; + /** + * Returns stack trace with given stackTraceId. + * @experimental + */ + post( + method: 'Debugger.getStackTrace', + params?: Debugger.GetStackTraceParameterType, + callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, + ): void; + post( + method: 'Debugger.getStackTrace', + callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, + ): void; + /** + * Searches for given string in script content. + */ + post( + method: 'Debugger.searchInContent', + params?: Debugger.SearchInContentParameterType, + callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, + ): void; + post( + method: 'Debugger.searchInContent', + callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, + ): void; + /** + * Edits JavaScript source live. + */ + post( + method: 'Debugger.setScriptSource', + params?: Debugger.SetScriptSourceParameterType, + callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, + ): void; + post( + method: 'Debugger.setScriptSource', + callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, + ): void; + /** + * Restarts particular call frame from the beginning. + */ + post( + method: 'Debugger.restartFrame', + params?: Debugger.RestartFrameParameterType, + callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, + ): void; + post( + method: 'Debugger.restartFrame', + callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, + ): void; + /** + * Returns source for the script with given id. + */ + post( + method: 'Debugger.getScriptSource', + params?: Debugger.GetScriptSourceParameterType, + callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, + ): void; + post( + method: 'Debugger.getScriptSource', + callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, + ): void; + /** + * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none. + */ + post( + method: 'Debugger.setPauseOnExceptions', + params?: Debugger.SetPauseOnExceptionsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setPauseOnExceptions', callback?: (err: Error | null) => void): void; + /** + * Evaluates expression on a given call frame. + */ + post( + method: 'Debugger.evaluateOnCallFrame', + params?: Debugger.EvaluateOnCallFrameParameterType, + callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, + ): void; + post( + method: 'Debugger.evaluateOnCallFrame', + callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, + ): void; + /** + * Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually. + */ + post( + method: 'Debugger.setVariableValue', + params?: Debugger.SetVariableValueParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setVariableValue', callback?: (err: Error | null) => void): void; + /** + * Changes return value in top frame. Available only at return break position. + * @experimental + */ + post( + method: 'Debugger.setReturnValue', + params?: Debugger.SetReturnValueParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setReturnValue', callback?: (err: Error | null) => void): void; + /** + * Enables or disables async call stacks tracking. + */ + post( + method: 'Debugger.setAsyncCallStackDepth', + params?: Debugger.SetAsyncCallStackDepthParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setAsyncCallStackDepth', callback?: (err: Error | null) => void): void; + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + * @experimental + */ + post( + method: 'Debugger.setBlackboxPatterns', + params?: Debugger.SetBlackboxPatternsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBlackboxPatterns', callback?: (err: Error | null) => void): void; + /** + * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted. + * @experimental + */ + post( + method: 'Debugger.setBlackboxedRanges', + params?: Debugger.SetBlackboxedRangesParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBlackboxedRanges', callback?: (err: Error | null) => void): void; + /** + * Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification. + */ + post(method: 'Console.enable', callback?: (err: Error | null) => void): void; + /** + * Disables console domain, prevents further console messages from being reported to the client. + */ + post(method: 'Console.disable', callback?: (err: Error | null) => void): void; + /** + * Does nothing. + */ + post(method: 'Console.clearMessages', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.disable', callback?: (err: Error | null) => void): void; + /** + * Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + */ + post( + method: 'Profiler.setSamplingInterval', + params?: Profiler.SetSamplingIntervalParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Profiler.setSamplingInterval', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.start', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.stop', callback?: (err: Error | null, params: Profiler.StopReturnType) => void): void; + /** + * Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters. + */ + post( + method: 'Profiler.startPreciseCoverage', + params?: Profiler.StartPreciseCoverageParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Profiler.startPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code. + */ + post(method: 'Profiler.stopPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started. + */ + post( + method: 'Profiler.takePreciseCoverage', + callback?: (err: Error | null, params: Profiler.TakePreciseCoverageReturnType) => void, + ): void; + /** + * Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection. + */ + post( + method: 'Profiler.getBestEffortCoverage', + callback?: (err: Error | null, params: Profiler.GetBestEffortCoverageReturnType) => void, + ): void; + /** + * Enable type profile. + * @experimental + */ + post(method: 'Profiler.startTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Disable type profile. Disabling releases type profile data collected so far. + * @experimental + */ + post(method: 'Profiler.stopTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Collect type profile. + * @experimental + */ + post( + method: 'Profiler.takeTypeProfile', + callback?: (err: Error | null, params: Profiler.TakeTypeProfileReturnType) => void, + ): void; + post(method: 'HeapProfiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.disable', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.startTrackingHeapObjects', + params?: HeapProfiler.StartTrackingHeapObjectsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.stopTrackingHeapObjects', + params?: HeapProfiler.StopTrackingHeapObjectsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.takeHeapSnapshot', + params?: HeapProfiler.TakeHeapSnapshotParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.takeHeapSnapshot', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.collectGarbage', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + params?: HeapProfiler.GetObjectByHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, + ): void; + /** + * Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). + */ + post( + method: 'HeapProfiler.addInspectedHeapObject', + params?: HeapProfiler.AddInspectedHeapObjectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.addInspectedHeapObject', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getHeapObjectId', + params?: HeapProfiler.GetHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getHeapObjectId', + callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.startSampling', + params?: HeapProfiler.StartSamplingParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.startSampling', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.stopSampling', + callback?: (err: Error | null, params: HeapProfiler.StopSamplingReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getSamplingProfile', + callback?: (err: Error | null, params: HeapProfiler.GetSamplingProfileReturnType) => void, + ): void; + /** + * Gets supported tracing categories. + */ + post( + method: 'NodeTracing.getCategories', + callback?: (err: Error | null, params: NodeTracing.GetCategoriesReturnType) => void, + ): void; + /** + * Start trace events collection. + */ + post( + method: 'NodeTracing.start', + params?: NodeTracing.StartParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeTracing.start', callback?: (err: Error | null) => void): void; + /** + * Stop trace events collection. Remaining collected events will be sent as a sequence of + * dataCollected events followed by tracingComplete event. + */ + post(method: 'NodeTracing.stop', callback?: (err: Error | null) => void): void; + /** + * Sends protocol message over session with given id. + */ + post( + method: 'NodeWorker.sendMessageToWorker', + params?: NodeWorker.SendMessageToWorkerParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.sendMessageToWorker', callback?: (err: Error | null) => void): void; + /** + * Instructs the inspector to attach to running workers. Will also attach to new workers + * as they start + */ + post( + method: 'NodeWorker.enable', + params?: NodeWorker.EnableParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.enable', callback?: (err: Error | null) => void): void; + /** + * Detaches from all running workers and disables attaching to new workers as they are started. + */ + post(method: 'NodeWorker.disable', callback?: (err: Error | null) => void): void; + /** + * Detached from the worker with given sessionId. + */ + post( + method: 'NodeWorker.detach', + params?: NodeWorker.DetachParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void; + /** + * Enable the `NodeRuntime.waitingForDisconnect`. + */ + post( + method: 'NodeRuntime.notifyWhenWaitingForDisconnect', + params?: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', callback?: (err: Error | null) => void): void; + // Events + addListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + addListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + addListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + addListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + addListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + addListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + addListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + addListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + addListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + addListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + addListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + addListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + addListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + addListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + addListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + addListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + addListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + addListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + addListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + addListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + addListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + addListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + addListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + addListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + addListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + addListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + addListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + addListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: 'inspectorNotification', message: InspectorNotification<{}>): boolean; + emit( + event: 'Runtime.executionContextCreated', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.executionContextDestroyed', + message: InspectorNotification, + ): boolean; + emit(event: 'Runtime.executionContextsCleared'): boolean; + emit( + event: 'Runtime.exceptionThrown', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.exceptionRevoked', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.consoleAPICalled', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.inspectRequested', + message: InspectorNotification, + ): boolean; + emit(event: 'Debugger.scriptParsed', message: InspectorNotification): boolean; + emit( + event: 'Debugger.scriptFailedToParse', + message: InspectorNotification, + ): boolean; + emit( + event: 'Debugger.breakpointResolved', + message: InspectorNotification, + ): boolean; + emit(event: 'Debugger.paused', message: InspectorNotification): boolean; + emit(event: 'Debugger.resumed'): boolean; + emit(event: 'Console.messageAdded', message: InspectorNotification): boolean; + emit( + event: 'Profiler.consoleProfileStarted', + message: InspectorNotification, + ): boolean; + emit( + event: 'Profiler.consoleProfileFinished', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.addHeapSnapshotChunk', + message: InspectorNotification, + ): boolean; + emit(event: 'HeapProfiler.resetProfiles'): boolean; + emit( + event: 'HeapProfiler.reportHeapSnapshotProgress', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.lastSeenObjectId', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.heapStatsUpdate', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeTracing.dataCollected', + message: InspectorNotification, + ): boolean; + emit(event: 'NodeTracing.tracingComplete'): boolean; + emit( + event: 'NodeWorker.attachedToWorker', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeWorker.detachedFromWorker', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeWorker.receivedMessageFromWorker', + message: InspectorNotification, + ): boolean; + emit(event: 'NodeRuntime.waitingForDisconnect'): boolean; + on(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + on(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + on( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + on( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + on(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + on( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + on( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + on( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + on( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + on( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + on( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + on( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + on( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + on(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + on( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + on( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + on( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + on( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + on(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + on( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + on( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + on( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + on( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + on(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + on( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + on( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + on( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + on(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + once(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + once( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + once( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + once(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + once( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + once( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + once( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + once( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + once( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + once( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + once( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + once( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + once(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + once( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + once( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + once( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + once( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + once(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + once( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + once( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + once( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + once( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + once(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + once( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + once( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + once( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + once(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + prependListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + prependListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + prependListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + prependListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + prependListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + prependListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + prependListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + prependListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependOnceListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependOnceListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + prependOnceListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependOnceListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependOnceListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + prependOnceListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + prependOnceListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependOnceListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependOnceListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependOnceListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependOnceListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependOnceListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependOnceListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependOnceListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependOnceListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependOnceListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependOnceListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependOnceListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + prependOnceListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependOnceListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependOnceListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + prependOnceListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependOnceListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + } + /** + * Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has + * started. + * + * If wait is `true`, will block until a client has connected to the inspect port + * and flow control has been passed to the debugger client. + * + * See the `security warning` regarding the `host`parameter usage. + * @param [port='what was specified on the CLI'] Port to listen on for inspector connections. Optional. + * @param [host='what was specified on the CLI'] Host to listen on for inspector connections. Optional. + * @param [wait=false] Block until a client has connected. Optional. + */ + function open(port?: number, host?: string, wait?: boolean): void; + /** + * Deactivate the inspector. Blocks until there are no active connections. + */ + function close(): void; + /** + * Return the URL of the active inspector, or `undefined` if there is none. + * + * ```console + * $ node --inspect -p 'inspector.url()' + * Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * For help, see: https://nodejs.org/en/docs/inspector + * ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * + * $ node --inspect=localhost:3000 -p 'inspector.url()' + * Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * For help, see: https://nodejs.org/en/docs/inspector + * ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * + * $ node -p 'inspector.url()' + * undefined + * ``` + */ + function url(): string | undefined; + /** + * Blocks until a client (existing or connected later) has sent`Runtime.runIfWaitingForDebugger` command. + * + * An exception will be thrown if there is no active inspector. + * @since v12.7.0 + */ + function waitForDebugger(): void; +} +/** + * The inspector module provides an API for interacting with the V8 inspector. + */ +declare module 'node:inspector' { + import inspector = require('inspector'); + export = inspector; +} diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts new file mode 100644 index 000000000000..c0e3e5a1803d --- /dev/null +++ b/packages/node/src/integrations/localvariables.ts @@ -0,0 +1,226 @@ +import { parseSemver } from '@sentry/utils'; + +const nodeVersion = parseSemver(process.versions.node); + +if ((nodeVersion.major || 0) < 14) { + throw new Error('The LocalVariables integration requires node.js >= v14'); +} + +import { Event, EventProcessor, Hub, Integration, StackFrame, StackParser } from '@sentry/types'; +import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; +import { LRUMap } from 'lru_map'; + +interface ExceptionData { + description: string; +} + +interface FrameVars { + function: string; + vars?: Record; +} + +/** + * Creates a unique hash from the stack frames + */ +function hashFrames(frames: StackFrame[] | undefined): string | undefined { + if (frames === undefined) { + return; + } + + return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); +} + +/** + * Promise API is available as `Experimental` and in Node 19 only. + * + * Callback-based API is `Stable` since v14 and `Experimental` since v8. + * Because of that, we are creating our own `AsyncSession` class. + * + * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api + * https://nodejs.org/docs/latest-v14.x/api/inspector.html + */ +class AsyncSession extends Session { + public async getProperties(objectId: string): Promise { + return new Promise((resolve, reject) => { + this.post( + 'Runtime.getProperties', + { + objectId, + ownProperties: true, + }, + (err, params) => { + if (err) { + reject(err); + } else { + resolve(params.result); + } + }, + ); + }); + } +} + +/** + * Adds local variables to exception frames + */ +export class LocalVariables implements Integration { + public static id: string = 'LocalVariables'; + + public name: string = LocalVariables.id; + + private readonly _session: AsyncSession; + private readonly _cachedFrameVars: LRUMap> = new LRUMap(50); + // We use the stack parser to create a unique hash from the exception stack trace + // This is used to lookup vars when + private _stackParser: StackParser | undefined; + + public constructor() { + this._session = new AsyncSession(); + this._session.connect(); + this._session.on('Debugger.paused', this._handlePaused.bind(this)); + this._session.post('Debugger.enable'); + // We only care about uncaught exceptions + this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); + } + + /** + * @inheritDoc + */ + public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + this._stackParser = getCurrentHub().getClient()?.getOptions().stackParser; + + addGlobalEventProcessor(async event => this._addLocalVariables(event)); + } + + /** + * Handle the pause event + */ + private async _handlePaused(event: InspectorNotification): Promise { + // We only care about exceptions for now + if (event.params.reason !== 'exception') { + return; + } + + const exceptionData = event.params?.data as ExceptionData | undefined; + + // event.params.data.description contains the original error.stack + const exceptionHash = + exceptionData?.description && this._stackParser + ? hashFrames(this._stackParser(exceptionData.description, 1)) + : undefined; + + if (exceptionHash == undefined) { + return; + } + + // We add the un-awaited promise to the cache rather than await here otherwise the event processor + // can be called before we're finished getting all the vars + const framesPromise: Promise = Promise.all( + event.params.callFrames.map(async callFrame => { + const localScope = callFrame.scopeChain.find(scope => scope.type === 'local'); + + if (localScope?.object.objectId) { + const vars = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); + + const fn = + callFrame.this.className !== 'global' + ? `${callFrame.this.className}.${callFrame.functionName}` + : callFrame.functionName; + + return { function: fn, vars }; + } + + return { function: callFrame.functionName }; + }), + ); + + this._cachedFrameVars.set(exceptionHash, framesPromise); + } + + /** + * Unrolls all the properties + */ + private async _unrollProps(props: Runtime.PropertyDescriptor[]): Promise> { + const unrolled: Record = {}; + + for (const prop of props) { + if (prop?.value?.objectId && prop?.value.className === 'Array') { + unrolled[prop.name] = await this._unrollArray(prop.value.objectId); + } else if (prop?.value?.objectId && prop?.value?.className === 'Object') { + unrolled[prop.name] = await this._unrollObject(prop.value.objectId); + } else if (prop?.value?.value || prop?.value?.description) { + unrolled[prop.name] = prop.value.value || `<${prop.value.description}>`; + } + } + + return unrolled; + } + + /** + * Unrolls an array property + */ + private async _unrollArray(objectId: string): Promise { + const props = await this._session.getProperties(objectId); + return props + .filter(v => v.name !== 'length') + .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) + .map(v => v?.value?.value); + } + + /** + * Unrolls an object property + */ + private async _unrollObject(objectId: string): Promise> { + const props = await this._session.getProperties(objectId); + return props + .map<[string, unknown]>(v => [v.name, v?.value?.value]) + .reduce((obj, [key, val]) => { + obj[key] = val; + return obj; + }, {} as Record); + } + + /** + * Adds local variables to the exception stack trace frames. + */ + private async _addLocalVariables(event: Event): Promise { + const hash = hashFrames(event?.exception?.values?.[0]?.stacktrace?.frames); + + if (hash === undefined) { + return event; + } + + // Check if we have local variables for an exception that matches the hash + const cachedFrameVars = await this._cachedFrameVars.get(hash); + + if (cachedFrameVars === undefined) { + return event; + } + + const frameCount = event?.exception?.values?.[0]?.stacktrace?.frames?.length || 0; + + for (let i = 0; i < frameCount; i++) { + const frameIndex = frameCount - i - 1; + + // Drop out if we run out of frames to match + if (!event?.exception?.values?.[0]?.stacktrace?.frames?.[frameIndex] || !cachedFrameVars[i]) { + break; + } + + if ( + // We're not interested in frames that are not in_app because the vars are not relevant + event.exception.values[0].stacktrace.frames[frameIndex].in_app === false || + // The function names need to match + event.exception.values[0].stacktrace.frames[frameIndex].function !== cachedFrameVars[i].function || + // We need to have vars to add + cachedFrameVars[i].vars === undefined + ) { + continue; + } + + event.exception.values[0].stacktrace.frames[frameIndex].vars = cachedFrameVars[i].vars; + } + + return event; + } +} diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index 42751525fbaa..b0a60d147fdb 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -13,6 +13,7 @@ import { GLOBAL_OBJ, logger, nodeStackLineParser, + parseSemver, stackParserFromStackParserOptions, } from '@sentry/utils'; import * as domain from 'domain'; @@ -107,6 +108,7 @@ export const defaultIntegrations = [ * * @see {@link NodeOptions} for documentation on configuration options. */ +// eslint-disable-next-line complexity export function init(options: NodeOptions = {}): void { const carrier = getMainCarrier(); const autoloadedIntegrations = carrier.__SENTRY__?.integrations || []; @@ -119,6 +121,14 @@ export function init(options: NodeOptions = {}): void { ...autoloadedIntegrations, ]; + const nodeVersion = parseSemver(process.versions.node); + + if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { LocalVariables } = require('./integrations/localvariables'); + options.defaultIntegrations.push(new LocalVariables()); + } + if (options.dsn === undefined && process.env.SENTRY_DSN) { options.dsn = process.env.SENTRY_DSN; } diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index d4ca5dd4900d..5dd9f16cddfe 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -11,6 +11,9 @@ export interface BaseNodeOptions { /** Sets an optional server name (device name) */ serverName?: string; + /** */ + includeStackLocals?: boolean; + // TODO (v8): Remove this in v8 /** * @deprecated Moved to constructor options of the `Http` integration. From f89101d76dda263718a758f6ba6bd2cad46ff8a2 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Fri, 9 Dec 2022 00:38:22 +0000 Subject: [PATCH 03/19] Fix dynamic loading of integration --- packages/node/src/sdk.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index b0a60d147fdb..f278ee656dfa 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -10,6 +10,7 @@ import { import { SessionStatus, StackParser } from '@sentry/types'; import { createStackParser, + dynamicRequire, GLOBAL_OBJ, logger, nodeStackLineParser, @@ -124,8 +125,11 @@ export function init(options: NodeOptions = {}): void { const nodeVersion = parseSemver(process.versions.node); if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const { LocalVariables } = require('./integrations/localvariables'); + const { LocalVariables } = dynamicRequire( + module, + './integrations/localvariables', + ) as typeof import('./integrations/localvariables'); + options.defaultIntegrations.push(new LocalVariables()); } From 5c03a9d97689242b70121bdb6973c02e15e4cb4f Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Fri, 9 Dec 2022 01:15:05 +0000 Subject: [PATCH 04/19] Lint --- packages/node/src/integrations/inspector.d.ts | 6718 ++++++++--------- .../node/src/integrations/localvariables.ts | 452 +- 2 files changed, 3585 insertions(+), 3585 deletions(-) diff --git a/packages/node/src/integrations/inspector.d.ts b/packages/node/src/integrations/inspector.d.ts index 8128d2ad14f7..527006910ee9 100644 --- a/packages/node/src/integrations/inspector.d.ts +++ b/packages/node/src/integrations/inspector.d.ts @@ -1,3359 +1,3359 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-unused-vars */ -/* eslint-disable @typescript-eslint/unified-signatures */ -/* eslint-disable @typescript-eslint/explicit-member-accessibility */ -/* eslint-disable max-lines */ -/* eslint-disable @typescript-eslint/ban-types */ -// Type definitions for inspector - -// These definitions were copied from: -// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d37bf642ed2f3fe403e405892e2eb4240a191bb0/types/node/inspector.d.ts - -/** - * The `inspector` module provides an API for interacting with the V8 inspector. - * - * It can be accessed using: - * - * ```js - * const inspector = require('inspector'); - * ``` - * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js) - */ -declare module 'inspector' { - import EventEmitter = require('node:events'); - interface InspectorNotification { - method: string; - params: T; - } - namespace Schema { - /** - * Description of the protocol domain. - */ - interface Domain { - /** - * Domain name. - */ - name: string; - /** - * Domain version. - */ - version: string; - } - interface GetDomainsReturnType { - /** - * List of supported domains. - */ - domains: Domain[]; - } - } - namespace Runtime { - /** - * Unique script identifier. - */ - type ScriptId = string; - /** - * Unique object identifier. - */ - type RemoteObjectId = string; - /** - * Primitive value which cannot be JSON-stringified. - */ - type UnserializableValue = string; - /** - * Mirror object referencing original JavaScript object. - */ - interface RemoteObject { - /** - * Object type. - */ - type: string; - /** - * Object subtype hint. Specified for object type values only. - */ - subtype?: string | undefined; - /** - * Object class (constructor) name. Specified for object type values only. - */ - className?: string | undefined; - /** - * Remote object value in case of primitive values or JSON values (if it was requested). - */ - value?: any; - /** - * Primitive value which can not be JSON-stringified does not have value, but gets this property. - */ - unserializableValue?: UnserializableValue | undefined; - /** - * String representation of the object. - */ - description?: string | undefined; - /** - * Unique object identifier (for non-primitive values). - */ - objectId?: RemoteObjectId | undefined; - /** - * Preview containing abbreviated property values. Specified for object type values only. - * @experimental - */ - preview?: ObjectPreview | undefined; - /** - * @experimental - */ - customPreview?: CustomPreview | undefined; - } - /** - * @experimental - */ - interface CustomPreview { - header: string; - hasBody: boolean; - formatterObjectId: RemoteObjectId; - bindRemoteObjectFunctionId: RemoteObjectId; - configObjectId?: RemoteObjectId | undefined; - } - /** - * Object containing abbreviated remote object value. - * @experimental - */ - interface ObjectPreview { - /** - * Object type. - */ - type: string; - /** - * Object subtype hint. Specified for object type values only. - */ - subtype?: string | undefined; - /** - * String representation of the object. - */ - description?: string | undefined; - /** - * True iff some of the properties or entries of the original object did not fit. - */ - overflow: boolean; - /** - * List of the properties. - */ - properties: PropertyPreview[]; - /** - * List of the entries. Specified for map and set subtype values only. - */ - entries?: EntryPreview[] | undefined; - } - /** - * @experimental - */ - interface PropertyPreview { - /** - * Property name. - */ - name: string; - /** - * Object type. Accessor means that the property itself is an accessor property. - */ - type: string; - /** - * User-friendly property value string. - */ - value?: string | undefined; - /** - * Nested value preview. - */ - valuePreview?: ObjectPreview | undefined; - /** - * Object subtype hint. Specified for object type values only. - */ - subtype?: string | undefined; - } - /** - * @experimental - */ - interface EntryPreview { - /** - * Preview of the key. Specified for map-like collection entries. - */ - key?: ObjectPreview | undefined; - /** - * Preview of the value. - */ - value: ObjectPreview; - } - /** - * Object property descriptor. - */ - interface PropertyDescriptor { - /** - * Property name or symbol description. - */ - name: string; - /** - * The value associated with the property. - */ - value?: RemoteObject | undefined; - /** - * True if the value associated with the property may be changed (data descriptors only). - */ - writable?: boolean | undefined; - /** - * A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only). - */ - get?: RemoteObject | undefined; - /** - * A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only). - */ - set?: RemoteObject | undefined; - /** - * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. - */ - configurable: boolean; - /** - * True if this property shows up during enumeration of the properties on the corresponding object. - */ - enumerable: boolean; - /** - * True if the result was thrown during the evaluation. - */ - wasThrown?: boolean | undefined; - /** - * True if the property is owned for the object. - */ - isOwn?: boolean | undefined; - /** - * Property symbol object, if the property is of the symbol type. - */ - symbol?: RemoteObject | undefined; - } - /** - * Object internal property descriptor. This property isn't normally visible in JavaScript code. - */ - interface InternalPropertyDescriptor { - /** - * Conventional property name. - */ - name: string; - /** - * The value associated with the property. - */ - value?: RemoteObject | undefined; - } - /** - * Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified. - */ - interface CallArgument { - /** - * Primitive value or serializable javascript object. - */ - value?: any; - /** - * Primitive value which can not be JSON-stringified. - */ - unserializableValue?: UnserializableValue | undefined; - /** - * Remote object handle. - */ - objectId?: RemoteObjectId | undefined; - } - /** - * Id of an execution context. - */ - type ExecutionContextId = number; - /** - * Description of an isolated world. - */ - interface ExecutionContextDescription { - /** - * Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed. - */ - id: ExecutionContextId; - /** - * Execution context origin. - */ - origin: string; - /** - * Human readable name describing given context. - */ - name: string; - /** - * Embedder-specific auxiliary data. - */ - auxData?: {} | undefined; - } - /** - * Detailed information about exception (or error) that was thrown during script compilation or execution. - */ - interface ExceptionDetails { - /** - * Exception id. - */ - exceptionId: number; - /** - * Exception text, which should be used together with exception object when available. - */ - text: string; - /** - * Line number of the exception location (0-based). - */ - lineNumber: number; - /** - * Column number of the exception location (0-based). - */ - columnNumber: number; - /** - * Script ID of the exception location. - */ - scriptId?: ScriptId | undefined; - /** - * URL of the exception location, to be used when the script was not reported. - */ - url?: string | undefined; - /** - * JavaScript stack trace if available. - */ - stackTrace?: StackTrace | undefined; - /** - * Exception object if available. - */ - exception?: RemoteObject | undefined; - /** - * Identifier of the context where exception happened. - */ - executionContextId?: ExecutionContextId | undefined; - } - /** - * Number of milliseconds since epoch. - */ - type Timestamp = number; - /** - * Stack entry for runtime errors and assertions. - */ - interface CallFrame { - /** - * JavaScript function name. - */ - functionName: string; - /** - * JavaScript script id. - */ - scriptId: ScriptId; - /** - * JavaScript script name or url. - */ - url: string; - /** - * JavaScript script line number (0-based). - */ - lineNumber: number; - /** - * JavaScript script column number (0-based). - */ - columnNumber: number; - } - /** - * Call frames for assertions or error messages. - */ - interface StackTrace { - /** - * String label of this stack trace. For async traces this may be a name of the function that initiated the async call. - */ - description?: string | undefined; - /** - * JavaScript function name. - */ - callFrames: CallFrame[]; - /** - * Asynchronous JavaScript stack trace that preceded this stack, if available. - */ - parent?: StackTrace | undefined; - /** - * Asynchronous JavaScript stack trace that preceded this stack, if available. - * @experimental - */ - parentId?: StackTraceId | undefined; - } - /** - * Unique identifier of current debugger. - * @experimental - */ - type UniqueDebuggerId = string; - /** - * If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages. - * @experimental - */ - interface StackTraceId { - id: string; - debuggerId?: UniqueDebuggerId | undefined; - } - interface EvaluateParameterType { - /** - * Expression to evaluate. - */ - expression: string; - /** - * Symbolic group name that can be used to release multiple objects. - */ - objectGroup?: string | undefined; - /** - * Determines whether Command Line API should be available during the evaluation. - */ - includeCommandLineAPI?: boolean | undefined; - /** - * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. - */ - silent?: boolean | undefined; - /** - * Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. - */ - contextId?: ExecutionContextId | undefined; - /** - * Whether the result is expected to be a JSON object that should be sent by value. - */ - returnByValue?: boolean | undefined; - /** - * Whether preview should be generated for the result. - * @experimental - */ - generatePreview?: boolean | undefined; - /** - * Whether execution should be treated as initiated by user in the UI. - */ - userGesture?: boolean | undefined; - /** - * Whether execution should await for resulting value and return once awaited promise is resolved. - */ - awaitPromise?: boolean | undefined; - } - interface AwaitPromiseParameterType { - /** - * Identifier of the promise. - */ - promiseObjectId: RemoteObjectId; - /** - * Whether the result is expected to be a JSON object that should be sent by value. - */ - returnByValue?: boolean | undefined; - /** - * Whether preview should be generated for the result. - */ - generatePreview?: boolean | undefined; - } - interface CallFunctionOnParameterType { - /** - * Declaration of the function to call. - */ - functionDeclaration: string; - /** - * Identifier of the object to call function on. Either objectId or executionContextId should be specified. - */ - objectId?: RemoteObjectId | undefined; - /** - * Call arguments. All call arguments must belong to the same JavaScript world as the target object. - */ - arguments?: CallArgument[] | undefined; - /** - * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. - */ - silent?: boolean | undefined; - /** - * Whether the result is expected to be a JSON object which should be sent by value. - */ - returnByValue?: boolean | undefined; - /** - * Whether preview should be generated for the result. - * @experimental - */ - generatePreview?: boolean | undefined; - /** - * Whether execution should be treated as initiated by user in the UI. - */ - userGesture?: boolean | undefined; - /** - * Whether execution should await for resulting value and return once awaited promise is resolved. - */ - awaitPromise?: boolean | undefined; - /** - * Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. - */ - executionContextId?: ExecutionContextId | undefined; - /** - * Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object. - */ - objectGroup?: string | undefined; - } - interface GetPropertiesParameterType { - /** - * Identifier of the object to return properties for. - */ - objectId: RemoteObjectId; - /** - * If true, returns properties belonging only to the element itself, not to its prototype chain. - */ - ownProperties?: boolean | undefined; - /** - * If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. - * @experimental - */ - accessorPropertiesOnly?: boolean | undefined; - /** - * Whether preview should be generated for the results. - * @experimental - */ - generatePreview?: boolean | undefined; - } - interface ReleaseObjectParameterType { - /** - * Identifier of the object to release. - */ - objectId: RemoteObjectId; - } - interface ReleaseObjectGroupParameterType { - /** - * Symbolic object group name. - */ - objectGroup: string; - } - interface SetCustomObjectFormatterEnabledParameterType { - enabled: boolean; - } - interface CompileScriptParameterType { - /** - * Expression to compile. - */ - expression: string; - /** - * Source url to be set for the script. - */ - sourceURL: string; - /** - * Specifies whether the compiled script should be persisted. - */ - persistScript: boolean; - /** - * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. - */ - executionContextId?: ExecutionContextId | undefined; - } - interface RunScriptParameterType { - /** - * Id of the script to run. - */ - scriptId: ScriptId; - /** - * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. - */ - executionContextId?: ExecutionContextId | undefined; - /** - * Symbolic group name that can be used to release multiple objects. - */ - objectGroup?: string | undefined; - /** - * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. - */ - silent?: boolean | undefined; - /** - * Determines whether Command Line API should be available during the evaluation. - */ - includeCommandLineAPI?: boolean | undefined; - /** - * Whether the result is expected to be a JSON object which should be sent by value. - */ - returnByValue?: boolean | undefined; - /** - * Whether preview should be generated for the result. - */ - generatePreview?: boolean | undefined; - /** - * Whether execution should await for resulting value and return once awaited promise is resolved. - */ - awaitPromise?: boolean | undefined; - } - interface QueryObjectsParameterType { - /** - * Identifier of the prototype to return objects for. - */ - prototypeObjectId: RemoteObjectId; - } - interface GlobalLexicalScopeNamesParameterType { - /** - * Specifies in which execution context to lookup global scope variables. - */ - executionContextId?: ExecutionContextId | undefined; - } - interface EvaluateReturnType { - /** - * Evaluation result. - */ - result: RemoteObject; - /** - * Exception details. - */ - exceptionDetails?: ExceptionDetails | undefined; - } - interface AwaitPromiseReturnType { - /** - * Promise result. Will contain rejected value if promise was rejected. - */ - result: RemoteObject; - /** - * Exception details if stack strace is available. - */ - exceptionDetails?: ExceptionDetails | undefined; - } - interface CallFunctionOnReturnType { - /** - * Call result. - */ - result: RemoteObject; - /** - * Exception details. - */ - exceptionDetails?: ExceptionDetails | undefined; - } - interface GetPropertiesReturnType { - /** - * Object properties. - */ - result: PropertyDescriptor[]; - /** - * Internal object properties (only of the element itself). - */ - internalProperties?: InternalPropertyDescriptor[] | undefined; - /** - * Exception details. - */ - exceptionDetails?: ExceptionDetails | undefined; - } - interface CompileScriptReturnType { - /** - * Id of the script. - */ - scriptId?: ScriptId | undefined; - /** - * Exception details. - */ - exceptionDetails?: ExceptionDetails | undefined; - } - interface RunScriptReturnType { - /** - * Run result. - */ - result: RemoteObject; - /** - * Exception details. - */ - exceptionDetails?: ExceptionDetails | undefined; - } - interface QueryObjectsReturnType { - /** - * Array with objects. - */ - objects: RemoteObject; - } - interface GlobalLexicalScopeNamesReturnType { - names: string[]; - } - interface ExecutionContextCreatedEventDataType { - /** - * A newly created execution context. - */ - context: ExecutionContextDescription; - } - interface ExecutionContextDestroyedEventDataType { - /** - * Id of the destroyed context - */ - executionContextId: ExecutionContextId; - } - interface ExceptionThrownEventDataType { - /** - * Timestamp of the exception. - */ - timestamp: Timestamp; - exceptionDetails: ExceptionDetails; - } - interface ExceptionRevokedEventDataType { - /** - * Reason describing why exception was revoked. - */ - reason: string; - /** - * The id of revoked exception, as reported in exceptionThrown. - */ - exceptionId: number; - } - interface ConsoleAPICalledEventDataType { - /** - * Type of the call. - */ - type: string; - /** - * Call arguments. - */ - args: RemoteObject[]; - /** - * Identifier of the context where the call was made. - */ - executionContextId: ExecutionContextId; - /** - * Call timestamp. - */ - timestamp: Timestamp; - /** - * Stack trace captured when the call was made. - */ - stackTrace?: StackTrace | undefined; - /** - * Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context. - * @experimental - */ - context?: string | undefined; - } - interface InspectRequestedEventDataType { - object: RemoteObject; - hints: {}; - } - } - namespace Debugger { - /** - * Breakpoint identifier. - */ - type BreakpointId = string; - /** - * Call frame identifier. - */ - type CallFrameId = string; - /** - * Location in the source code. - */ - interface Location { - /** - * Script identifier as reported in the Debugger.scriptParsed. - */ - scriptId: Runtime.ScriptId; - /** - * Line number in the script (0-based). - */ - lineNumber: number; - /** - * Column number in the script (0-based). - */ - columnNumber?: number | undefined; - } - /** - * Location in the source code. - * @experimental - */ - interface ScriptPosition { - lineNumber: number; - columnNumber: number; - } - /** - * JavaScript call frame. Array of call frames form the call stack. - */ - interface CallFrame { - /** - * Call frame identifier. This identifier is only valid while the virtual machine is paused. - */ - callFrameId: CallFrameId; - /** - * Name of the JavaScript function called on this call frame. - */ - functionName: string; - /** - * Location in the source code. - */ - functionLocation?: Location | undefined; - /** - * Location in the source code. - */ - location: Location; - /** - * JavaScript script name or url. - */ - url: string; - /** - * Scope chain for this call frame. - */ - scopeChain: Scope[]; - /** - * this object for this call frame. - */ - this: Runtime.RemoteObject; - /** - * The value being returned, if the function is at return point. - */ - returnValue?: Runtime.RemoteObject | undefined; - } - /** - * Scope description. - */ - interface Scope { - /** - * Scope type. - */ - type: string; - /** - * Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties. - */ - object: Runtime.RemoteObject; - name?: string | undefined; - /** - * Location in the source code where scope starts - */ - startLocation?: Location | undefined; - /** - * Location in the source code where scope ends - */ - endLocation?: Location | undefined; - } - /** - * Search match for resource. - */ - interface SearchMatch { - /** - * Line number in resource content. - */ - lineNumber: number; - /** - * Line with match content. - */ - lineContent: string; - } - interface BreakLocation { - /** - * Script identifier as reported in the Debugger.scriptParsed. - */ - scriptId: Runtime.ScriptId; - /** - * Line number in the script (0-based). - */ - lineNumber: number; - /** - * Column number in the script (0-based). - */ - columnNumber?: number | undefined; - type?: string | undefined; - } - interface SetBreakpointsActiveParameterType { - /** - * New value for breakpoints active state. - */ - active: boolean; - } - interface SetSkipAllPausesParameterType { - /** - * New value for skip pauses state. - */ - skip: boolean; - } - interface SetBreakpointByUrlParameterType { - /** - * Line number to set breakpoint at. - */ - lineNumber: number; - /** - * URL of the resources to set breakpoint on. - */ - url?: string | undefined; - /** - * Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. - */ - urlRegex?: string | undefined; - /** - * Script hash of the resources to set breakpoint on. - */ - scriptHash?: string | undefined; - /** - * Offset in the line to set breakpoint at. - */ - columnNumber?: number | undefined; - /** - * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. - */ - condition?: string | undefined; - } - interface SetBreakpointParameterType { - /** - * Location to set breakpoint in. - */ - location: Location; - /** - * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. - */ - condition?: string | undefined; - } - interface RemoveBreakpointParameterType { - breakpointId: BreakpointId; - } - interface GetPossibleBreakpointsParameterType { - /** - * Start of range to search possible breakpoint locations in. - */ - start: Location; - /** - * End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. - */ - end?: Location | undefined; - /** - * Only consider locations which are in the same (non-nested) function as start. - */ - restrictToFunction?: boolean | undefined; - } - interface ContinueToLocationParameterType { - /** - * Location to continue to. - */ - location: Location; - targetCallFrames?: string | undefined; - } - interface PauseOnAsyncCallParameterType { - /** - * Debugger will pause when async call with given stack trace is started. - */ - parentStackTraceId: Runtime.StackTraceId; - } - interface StepIntoParameterType { - /** - * Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. - * @experimental - */ - breakOnAsyncCall?: boolean | undefined; - } - interface GetStackTraceParameterType { - stackTraceId: Runtime.StackTraceId; - } - interface SearchInContentParameterType { - /** - * Id of the script to search in. - */ - scriptId: Runtime.ScriptId; - /** - * String to search for. - */ - query: string; - /** - * If true, search is case sensitive. - */ - caseSensitive?: boolean | undefined; - /** - * If true, treats string parameter as regex. - */ - isRegex?: boolean | undefined; - } - interface SetScriptSourceParameterType { - /** - * Id of the script to edit. - */ - scriptId: Runtime.ScriptId; - /** - * New content of the script. - */ - scriptSource: string; - /** - * If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. - */ - dryRun?: boolean | undefined; - } - interface RestartFrameParameterType { - /** - * Call frame identifier to evaluate on. - */ - callFrameId: CallFrameId; - } - interface GetScriptSourceParameterType { - /** - * Id of the script to get source for. - */ - scriptId: Runtime.ScriptId; - } - interface SetPauseOnExceptionsParameterType { - /** - * Pause on exceptions mode. - */ - state: string; - } - interface EvaluateOnCallFrameParameterType { - /** - * Call frame identifier to evaluate on. - */ - callFrameId: CallFrameId; - /** - * Expression to evaluate. - */ - expression: string; - /** - * String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup). - */ - objectGroup?: string | undefined; - /** - * Specifies whether command line API should be available to the evaluated expression, defaults to false. - */ - includeCommandLineAPI?: boolean | undefined; - /** - * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. - */ - silent?: boolean | undefined; - /** - * Whether the result is expected to be a JSON object that should be sent by value. - */ - returnByValue?: boolean | undefined; - /** - * Whether preview should be generated for the result. - * @experimental - */ - generatePreview?: boolean | undefined; - /** - * Whether to throw an exception if side effect cannot be ruled out during evaluation. - */ - throwOnSideEffect?: boolean | undefined; - } - interface SetVariableValueParameterType { - /** - * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. - */ - scopeNumber: number; - /** - * Variable name. - */ - variableName: string; - /** - * New variable value. - */ - newValue: Runtime.CallArgument; - /** - * Id of callframe that holds variable. - */ - callFrameId: CallFrameId; - } - interface SetReturnValueParameterType { - /** - * New return value. - */ - newValue: Runtime.CallArgument; - } - interface SetAsyncCallStackDepthParameterType { - /** - * Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default). - */ - maxDepth: number; - } - interface SetBlackboxPatternsParameterType { - /** - * Array of regexps that will be used to check script url for blackbox state. - */ - patterns: string[]; - } - interface SetBlackboxedRangesParameterType { - /** - * Id of the script. - */ - scriptId: Runtime.ScriptId; - positions: ScriptPosition[]; - } - interface EnableReturnType { - /** - * Unique identifier of the debugger. - * @experimental - */ - debuggerId: Runtime.UniqueDebuggerId; - } - interface SetBreakpointByUrlReturnType { - /** - * Id of the created breakpoint for further reference. - */ - breakpointId: BreakpointId; - /** - * List of the locations this breakpoint resolved into upon addition. - */ - locations: Location[]; - } - interface SetBreakpointReturnType { - /** - * Id of the created breakpoint for further reference. - */ - breakpointId: BreakpointId; - /** - * Location this breakpoint resolved into. - */ - actualLocation: Location; - } - interface GetPossibleBreakpointsReturnType { - /** - * List of the possible breakpoint locations. - */ - locations: BreakLocation[]; - } - interface GetStackTraceReturnType { - stackTrace: Runtime.StackTrace; - } - interface SearchInContentReturnType { - /** - * List of search matches. - */ - result: SearchMatch[]; - } - interface SetScriptSourceReturnType { - /** - * New stack trace in case editing has happened while VM was stopped. - */ - callFrames?: CallFrame[] | undefined; - /** - * Whether current call stack was modified after applying the changes. - */ - stackChanged?: boolean | undefined; - /** - * Async stack trace, if any. - */ - asyncStackTrace?: Runtime.StackTrace | undefined; - /** - * Async stack trace, if any. - * @experimental - */ - asyncStackTraceId?: Runtime.StackTraceId | undefined; - /** - * Exception details if any. - */ - exceptionDetails?: Runtime.ExceptionDetails | undefined; - } - interface RestartFrameReturnType { - /** - * New stack trace. - */ - callFrames: CallFrame[]; - /** - * Async stack trace, if any. - */ - asyncStackTrace?: Runtime.StackTrace | undefined; - /** - * Async stack trace, if any. - * @experimental - */ - asyncStackTraceId?: Runtime.StackTraceId | undefined; - } - interface GetScriptSourceReturnType { - /** - * Script source. - */ - scriptSource: string; - } - interface EvaluateOnCallFrameReturnType { - /** - * Object wrapper for the evaluation result. - */ - result: Runtime.RemoteObject; - /** - * Exception details. - */ - exceptionDetails?: Runtime.ExceptionDetails | undefined; - } - interface ScriptParsedEventDataType { - /** - * Identifier of the script parsed. - */ - scriptId: Runtime.ScriptId; - /** - * URL or name of the script parsed (if any). - */ - url: string; - /** - * Line offset of the script within the resource with given URL (for script tags). - */ - startLine: number; - /** - * Column offset of the script within the resource with given URL. - */ - startColumn: number; - /** - * Last line of the script. - */ - endLine: number; - /** - * Length of the last line of the script. - */ - endColumn: number; - /** - * Specifies script creation context. - */ - executionContextId: Runtime.ExecutionContextId; - /** - * Content hash of the script. - */ - hash: string; - /** - * Embedder-specific auxiliary data. - */ - executionContextAuxData?: {} | undefined; - /** - * True, if this script is generated as a result of the live edit operation. - * @experimental - */ - isLiveEdit?: boolean | undefined; - /** - * URL of source map associated with script (if any). - */ - sourceMapURL?: string | undefined; - /** - * True, if this script has sourceURL. - */ - hasSourceURL?: boolean | undefined; - /** - * True, if this script is ES6 module. - */ - isModule?: boolean | undefined; - /** - * This script length. - */ - length?: number | undefined; - /** - * JavaScript top stack frame of where the script parsed event was triggered if available. - * @experimental - */ - stackTrace?: Runtime.StackTrace | undefined; - } - interface ScriptFailedToParseEventDataType { - /** - * Identifier of the script parsed. - */ - scriptId: Runtime.ScriptId; - /** - * URL or name of the script parsed (if any). - */ - url: string; - /** - * Line offset of the script within the resource with given URL (for script tags). - */ - startLine: number; - /** - * Column offset of the script within the resource with given URL. - */ - startColumn: number; - /** - * Last line of the script. - */ - endLine: number; - /** - * Length of the last line of the script. - */ - endColumn: number; - /** - * Specifies script creation context. - */ - executionContextId: Runtime.ExecutionContextId; - /** - * Content hash of the script. - */ - hash: string; - /** - * Embedder-specific auxiliary data. - */ - executionContextAuxData?: {} | undefined; - /** - * URL of source map associated with script (if any). - */ - sourceMapURL?: string | undefined; - /** - * True, if this script has sourceURL. - */ - hasSourceURL?: boolean | undefined; - /** - * True, if this script is ES6 module. - */ - isModule?: boolean | undefined; - /** - * This script length. - */ - length?: number | undefined; - /** - * JavaScript top stack frame of where the script parsed event was triggered if available. - * @experimental - */ - stackTrace?: Runtime.StackTrace | undefined; - } - interface BreakpointResolvedEventDataType { - /** - * Breakpoint unique identifier. - */ - breakpointId: BreakpointId; - /** - * Actual breakpoint location. - */ - location: Location; - } - interface PausedEventDataType { - /** - * Call stack the virtual machine stopped on. - */ - callFrames: CallFrame[]; - /** - * Pause reason. - */ - reason: string; - /** - * Object containing break-specific auxiliary properties. - */ - data?: {} | undefined; - /** - * Hit breakpoints IDs - */ - hitBreakpoints?: string[] | undefined; - /** - * Async stack trace, if any. - */ - asyncStackTrace?: Runtime.StackTrace | undefined; - /** - * Async stack trace, if any. - * @experimental - */ - asyncStackTraceId?: Runtime.StackTraceId | undefined; - /** - * Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag. - * @experimental - */ - asyncCallStackTraceId?: Runtime.StackTraceId | undefined; - } - } - namespace Console { - /** - * Console message. - */ - interface ConsoleMessage { - /** - * Message source. - */ - source: string; - /** - * Message severity. - */ - level: string; - /** - * Message text. - */ - text: string; - /** - * URL of the message origin. - */ - url?: string | undefined; - /** - * Line number in the resource that generated this message (1-based). - */ - line?: number | undefined; - /** - * Column number in the resource that generated this message (1-based). - */ - column?: number | undefined; - } - interface MessageAddedEventDataType { - /** - * Console message that has been added. - */ - message: ConsoleMessage; - } - } - namespace Profiler { - /** - * Profile node. Holds callsite information, execution statistics and child nodes. - */ - interface ProfileNode { - /** - * Unique id of the node. - */ - id: number; - /** - * Function location. - */ - callFrame: Runtime.CallFrame; - /** - * Number of samples where this node was on top of the call stack. - */ - hitCount?: number | undefined; - /** - * Child node ids. - */ - children?: number[] | undefined; - /** - * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. - */ - deoptReason?: string | undefined; - /** - * An array of source position ticks. - */ - positionTicks?: PositionTickInfo[] | undefined; - } - /** - * Profile. - */ - interface Profile { - /** - * The list of profile nodes. First item is the root node. - */ - nodes: ProfileNode[]; - /** - * Profiling start timestamp in microseconds. - */ - startTime: number; - /** - * Profiling end timestamp in microseconds. - */ - endTime: number; - /** - * Ids of samples top nodes. - */ - samples?: number[] | undefined; - /** - * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. - */ - timeDeltas?: number[] | undefined; - } - /** - * Specifies a number of samples attributed to a certain source position. - */ - interface PositionTickInfo { - /** - * Source line number (1-based). - */ - line: number; - /** - * Number of samples attributed to the source line. - */ - ticks: number; - } - /** - * Coverage data for a source range. - */ - interface CoverageRange { - /** - * JavaScript script source offset for the range start. - */ - startOffset: number; - /** - * JavaScript script source offset for the range end. - */ - endOffset: number; - /** - * Collected execution count of the source range. - */ - count: number; - } - /** - * Coverage data for a JavaScript function. - */ - interface FunctionCoverage { - /** - * JavaScript function name. - */ - functionName: string; - /** - * Source ranges inside the function with coverage data. - */ - ranges: CoverageRange[]; - /** - * Whether coverage data for this function has block granularity. - */ - isBlockCoverage: boolean; - } - /** - * Coverage data for a JavaScript script. - */ - interface ScriptCoverage { - /** - * JavaScript script id. - */ - scriptId: Runtime.ScriptId; - /** - * JavaScript script name or url. - */ - url: string; - /** - * Functions contained in the script that has coverage data. - */ - functions: FunctionCoverage[]; - } - /** - * Describes a type collected during runtime. - * @experimental - */ - interface TypeObject { - /** - * Name of a type collected with type profiling. - */ - name: string; - } - /** - * Source offset and types for a parameter or return value. - * @experimental - */ - interface TypeProfileEntry { - /** - * Source offset of the parameter or end of function for return values. - */ - offset: number; - /** - * The types for this parameter or return value. - */ - types: TypeObject[]; - } - /** - * Type profile data collected during runtime for a JavaScript script. - * @experimental - */ - interface ScriptTypeProfile { - /** - * JavaScript script id. - */ - scriptId: Runtime.ScriptId; - /** - * JavaScript script name or url. - */ - url: string; - /** - * Type profile entries for parameters and return values of the functions in the script. - */ - entries: TypeProfileEntry[]; - } - interface SetSamplingIntervalParameterType { - /** - * New sampling interval in microseconds. - */ - interval: number; - } - interface StartPreciseCoverageParameterType { - /** - * Collect accurate call counts beyond simple 'covered' or 'not covered'. - */ - callCount?: boolean | undefined; - /** - * Collect block-based coverage. - */ - detailed?: boolean | undefined; - } - interface StopReturnType { - /** - * Recorded profile. - */ - profile: Profile; - } - interface TakePreciseCoverageReturnType { - /** - * Coverage data for the current isolate. - */ - result: ScriptCoverage[]; - } - interface GetBestEffortCoverageReturnType { - /** - * Coverage data for the current isolate. - */ - result: ScriptCoverage[]; - } - interface TakeTypeProfileReturnType { - /** - * Type profile for all scripts since startTypeProfile() was turned on. - */ - result: ScriptTypeProfile[]; - } - interface ConsoleProfileStartedEventDataType { - id: string; - /** - * Location of console.profile(). - */ - location: Debugger.Location; - /** - * Profile title passed as an argument to console.profile(). - */ - title?: string | undefined; - } - interface ConsoleProfileFinishedEventDataType { - id: string; - /** - * Location of console.profileEnd(). - */ - location: Debugger.Location; - profile: Profile; - /** - * Profile title passed as an argument to console.profile(). - */ - title?: string | undefined; - } - } - namespace HeapProfiler { - /** - * Heap snapshot object id. - */ - type HeapSnapshotObjectId = string; - /** - * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. - */ - interface SamplingHeapProfileNode { - /** - * Function location. - */ - callFrame: Runtime.CallFrame; - /** - * Allocations size in bytes for the node excluding children. - */ - selfSize: number; - /** - * Child nodes. - */ - children: SamplingHeapProfileNode[]; - } - /** - * Profile. - */ - interface SamplingHeapProfile { - head: SamplingHeapProfileNode; - } - interface StartTrackingHeapObjectsParameterType { - trackAllocations?: boolean | undefined; - } - interface StopTrackingHeapObjectsParameterType { - /** - * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. - */ - reportProgress?: boolean | undefined; - } - interface TakeHeapSnapshotParameterType { - /** - * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. - */ - reportProgress?: boolean | undefined; - } - interface GetObjectByHeapObjectIdParameterType { - objectId: HeapSnapshotObjectId; - /** - * Symbolic group name that can be used to release multiple objects. - */ - objectGroup?: string | undefined; - } - interface AddInspectedHeapObjectParameterType { - /** - * Heap snapshot object id to be accessible by means of $x command line API. - */ - heapObjectId: HeapSnapshotObjectId; - } - interface GetHeapObjectIdParameterType { - /** - * Identifier of the object to get heap object id for. - */ - objectId: Runtime.RemoteObjectId; - } - interface StartSamplingParameterType { - /** - * Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. - */ - samplingInterval?: number | undefined; - } - interface GetObjectByHeapObjectIdReturnType { - /** - * Evaluation result. - */ - result: Runtime.RemoteObject; - } - interface GetHeapObjectIdReturnType { - /** - * Id of the heap snapshot object corresponding to the passed remote object id. - */ - heapSnapshotObjectId: HeapSnapshotObjectId; - } - interface StopSamplingReturnType { - /** - * Recorded sampling heap profile. - */ - profile: SamplingHeapProfile; - } - interface GetSamplingProfileReturnType { - /** - * Return the sampling profile being collected. - */ - profile: SamplingHeapProfile; - } - interface AddHeapSnapshotChunkEventDataType { - chunk: string; - } - interface ReportHeapSnapshotProgressEventDataType { - done: number; - total: number; - finished?: boolean | undefined; - } - interface LastSeenObjectIdEventDataType { - lastSeenObjectId: number; - timestamp: number; - } - interface HeapStatsUpdateEventDataType { - /** - * An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. - */ - statsUpdate: number[]; - } - } - namespace NodeTracing { - interface TraceConfig { - /** - * Controls how the trace buffer stores data. - */ - recordMode?: string | undefined; - /** - * Included category filters. - */ - includedCategories: string[]; - } - interface StartParameterType { - traceConfig: TraceConfig; - } - interface GetCategoriesReturnType { - /** - * A list of supported tracing categories. - */ - categories: string[]; - } - interface DataCollectedEventDataType { - value: Array<{}>; - } - } - namespace NodeWorker { - type WorkerID = string; - /** - * Unique identifier of attached debugging session. - */ - type SessionID = string; - interface WorkerInfo { - workerId: WorkerID; - type: string; - title: string; - url: string; - } - interface SendMessageToWorkerParameterType { - message: string; - /** - * Identifier of the session. - */ - sessionId: SessionID; - } - interface EnableParameterType { - /** - * Whether to new workers should be paused until the frontend sends `Runtime.runIfWaitingForDebugger` - * message to run them. - */ - waitForDebuggerOnStart: boolean; - } - interface DetachParameterType { - sessionId: SessionID; - } - interface AttachedToWorkerEventDataType { - /** - * Identifier assigned to the session used to send/receive messages. - */ - sessionId: SessionID; - workerInfo: WorkerInfo; - waitingForDebugger: boolean; - } - interface DetachedFromWorkerEventDataType { - /** - * Detached session identifier. - */ - sessionId: SessionID; - } - interface ReceivedMessageFromWorkerEventDataType { - /** - * Identifier of a session which sends a message. - */ - sessionId: SessionID; - message: string; - } - } - namespace NodeRuntime { - interface NotifyWhenWaitingForDisconnectParameterType { - enabled: boolean; - } - } - /** - * The `inspector.Session` is used for dispatching messages to the V8 inspector - * back-end and receiving message responses and notifications. - */ - class Session extends EventEmitter { - /** - * Create a new instance of the inspector.Session class. - * The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend. - */ - constructor(); - /** - * Connects a session to the inspector back-end. - * @since v8.0.0 - */ - connect(): void; - /** - * Immediately close the session. All pending message callbacks will be called - * with an error. `session.connect()` will need to be called to be able to send - * messages again. Reconnected session will lose all inspector state, such as - * enabled agents or configured breakpoints. - * @since v8.0.0 - */ - disconnect(): void; - /** - * Posts a message to the inspector back-end. `callback` will be notified when - * a response is received. `callback` is a function that accepts two optional - * arguments: error and message-specific result. - * - * ```js - * session.post('Runtime.evaluate', { expression: '2 + 2' }, - * (error, { result }) => console.log(result)); - * // Output: { type: 'number', value: 4, description: '4' } - * ``` - * - * The latest version of the V8 inspector protocol is published on the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/v8/). - * - * Node.js inspector supports all the Chrome DevTools Protocol domains declared - * by V8\. Chrome DevTools Protocol domain provides an interface for interacting - * with one of the runtime agents used to inspect the application state and listen - * to the run-time events. - * - * ## Example usage - * - * Apart from the debugger, various V8 Profilers are available through the DevTools - * protocol. - * @since v8.0.0 - */ - post(method: string, params?: {}, callback?: (err: Error | null, params?: {}) => void): void; - post(method: string, callback?: (err: Error | null, params?: {}) => void): void; - /** - * Returns supported domains. - */ - post( - method: 'Schema.getDomains', - callback?: (err: Error | null, params: Schema.GetDomainsReturnType) => void, - ): void; - /** - * Evaluates expression on global object. - */ - post( - method: 'Runtime.evaluate', - params?: Runtime.EvaluateParameterType, - callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void, - ): void; - post(method: 'Runtime.evaluate', callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; - /** - * Add handler to promise with given promise object id. - */ - post( - method: 'Runtime.awaitPromise', - params?: Runtime.AwaitPromiseParameterType, - callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, - ): void; - post( - method: 'Runtime.awaitPromise', - callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, - ): void; - /** - * Calls function with given declaration on the given object. Object group of the result is inherited from the target object. - */ - post( - method: 'Runtime.callFunctionOn', - params?: Runtime.CallFunctionOnParameterType, - callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, - ): void; - post( - method: 'Runtime.callFunctionOn', - callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, - ): void; - /** - * Returns properties of a given object. Object group of the result is inherited from the target object. - */ - post( - method: 'Runtime.getProperties', - params?: Runtime.GetPropertiesParameterType, - callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, - ): void; - post( - method: 'Runtime.getProperties', - callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, - ): void; - /** - * Releases remote object with given id. - */ - post( - method: 'Runtime.releaseObject', - params?: Runtime.ReleaseObjectParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Runtime.releaseObject', callback?: (err: Error | null) => void): void; - /** - * Releases all remote objects that belong to a given group. - */ - post( - method: 'Runtime.releaseObjectGroup', - params?: Runtime.ReleaseObjectGroupParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Runtime.releaseObjectGroup', callback?: (err: Error | null) => void): void; - /** - * Tells inspected instance to run if it was waiting for debugger to attach. - */ - post(method: 'Runtime.runIfWaitingForDebugger', callback?: (err: Error | null) => void): void; - /** - * Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context. - */ - post(method: 'Runtime.enable', callback?: (err: Error | null) => void): void; - /** - * Disables reporting of execution contexts creation. - */ - post(method: 'Runtime.disable', callback?: (err: Error | null) => void): void; - /** - * Discards collected exceptions and console API calls. - */ - post(method: 'Runtime.discardConsoleEntries', callback?: (err: Error | null) => void): void; - /** - * @experimental - */ - post( - method: 'Runtime.setCustomObjectFormatterEnabled', - params?: Runtime.SetCustomObjectFormatterEnabledParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Runtime.setCustomObjectFormatterEnabled', callback?: (err: Error | null) => void): void; - /** - * Compiles expression. - */ - post( - method: 'Runtime.compileScript', - params?: Runtime.CompileScriptParameterType, - callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, - ): void; - post( - method: 'Runtime.compileScript', - callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, - ): void; - /** - * Runs script with given id in a given context. - */ - post( - method: 'Runtime.runScript', - params?: Runtime.RunScriptParameterType, - callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, - ): void; - post( - method: 'Runtime.runScript', - callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, - ): void; - post( - method: 'Runtime.queryObjects', - params?: Runtime.QueryObjectsParameterType, - callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, - ): void; - post( - method: 'Runtime.queryObjects', - callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, - ): void; - /** - * Returns all let, const and class variables from global scope. - */ - post( - method: 'Runtime.globalLexicalScopeNames', - params?: Runtime.GlobalLexicalScopeNamesParameterType, - callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, - ): void; - post( - method: 'Runtime.globalLexicalScopeNames', - callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, - ): void; - /** - * Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received. - */ - post(method: 'Debugger.enable', callback?: (err: Error | null, params: Debugger.EnableReturnType) => void): void; - /** - * Disables debugger for given page. - */ - post(method: 'Debugger.disable', callback?: (err: Error | null) => void): void; - /** - * Activates / deactivates all breakpoints on the page. - */ - post( - method: 'Debugger.setBreakpointsActive', - params?: Debugger.SetBreakpointsActiveParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setBreakpointsActive', callback?: (err: Error | null) => void): void; - /** - * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). - */ - post( - method: 'Debugger.setSkipAllPauses', - params?: Debugger.SetSkipAllPausesParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setSkipAllPauses', callback?: (err: Error | null) => void): void; - /** - * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads. - */ - post( - method: 'Debugger.setBreakpointByUrl', - params?: Debugger.SetBreakpointByUrlParameterType, - callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, - ): void; - post( - method: 'Debugger.setBreakpointByUrl', - callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, - ): void; - /** - * Sets JavaScript breakpoint at a given location. - */ - post( - method: 'Debugger.setBreakpoint', - params?: Debugger.SetBreakpointParameterType, - callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, - ): void; - post( - method: 'Debugger.setBreakpoint', - callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, - ): void; - /** - * Removes JavaScript breakpoint. - */ - post( - method: 'Debugger.removeBreakpoint', - params?: Debugger.RemoveBreakpointParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.removeBreakpoint', callback?: (err: Error | null) => void): void; - /** - * Returns possible locations for breakpoint. scriptId in start and end range locations should be the same. - */ - post( - method: 'Debugger.getPossibleBreakpoints', - params?: Debugger.GetPossibleBreakpointsParameterType, - callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, - ): void; - post( - method: 'Debugger.getPossibleBreakpoints', - callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, - ): void; - /** - * Continues execution until specific location is reached. - */ - post( - method: 'Debugger.continueToLocation', - params?: Debugger.ContinueToLocationParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.continueToLocation', callback?: (err: Error | null) => void): void; - /** - * @experimental - */ - post( - method: 'Debugger.pauseOnAsyncCall', - params?: Debugger.PauseOnAsyncCallParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.pauseOnAsyncCall', callback?: (err: Error | null) => void): void; - /** - * Steps over the statement. - */ - post(method: 'Debugger.stepOver', callback?: (err: Error | null) => void): void; - /** - * Steps into the function call. - */ - post( - method: 'Debugger.stepInto', - params?: Debugger.StepIntoParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.stepInto', callback?: (err: Error | null) => void): void; - /** - * Steps out of the function call. - */ - post(method: 'Debugger.stepOut', callback?: (err: Error | null) => void): void; - /** - * Stops on the next JavaScript statement. - */ - post(method: 'Debugger.pause', callback?: (err: Error | null) => void): void; - /** - * This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called. - * @experimental - */ - post(method: 'Debugger.scheduleStepIntoAsync', callback?: (err: Error | null) => void): void; - /** - * Resumes JavaScript execution. - */ - post(method: 'Debugger.resume', callback?: (err: Error | null) => void): void; - /** - * Returns stack trace with given stackTraceId. - * @experimental - */ - post( - method: 'Debugger.getStackTrace', - params?: Debugger.GetStackTraceParameterType, - callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, - ): void; - post( - method: 'Debugger.getStackTrace', - callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, - ): void; - /** - * Searches for given string in script content. - */ - post( - method: 'Debugger.searchInContent', - params?: Debugger.SearchInContentParameterType, - callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, - ): void; - post( - method: 'Debugger.searchInContent', - callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, - ): void; - /** - * Edits JavaScript source live. - */ - post( - method: 'Debugger.setScriptSource', - params?: Debugger.SetScriptSourceParameterType, - callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, - ): void; - post( - method: 'Debugger.setScriptSource', - callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, - ): void; - /** - * Restarts particular call frame from the beginning. - */ - post( - method: 'Debugger.restartFrame', - params?: Debugger.RestartFrameParameterType, - callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, - ): void; - post( - method: 'Debugger.restartFrame', - callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, - ): void; - /** - * Returns source for the script with given id. - */ - post( - method: 'Debugger.getScriptSource', - params?: Debugger.GetScriptSourceParameterType, - callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, - ): void; - post( - method: 'Debugger.getScriptSource', - callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, - ): void; - /** - * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none. - */ - post( - method: 'Debugger.setPauseOnExceptions', - params?: Debugger.SetPauseOnExceptionsParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setPauseOnExceptions', callback?: (err: Error | null) => void): void; - /** - * Evaluates expression on a given call frame. - */ - post( - method: 'Debugger.evaluateOnCallFrame', - params?: Debugger.EvaluateOnCallFrameParameterType, - callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, - ): void; - post( - method: 'Debugger.evaluateOnCallFrame', - callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, - ): void; - /** - * Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually. - */ - post( - method: 'Debugger.setVariableValue', - params?: Debugger.SetVariableValueParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setVariableValue', callback?: (err: Error | null) => void): void; - /** - * Changes return value in top frame. Available only at return break position. - * @experimental - */ - post( - method: 'Debugger.setReturnValue', - params?: Debugger.SetReturnValueParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setReturnValue', callback?: (err: Error | null) => void): void; - /** - * Enables or disables async call stacks tracking. - */ - post( - method: 'Debugger.setAsyncCallStackDepth', - params?: Debugger.SetAsyncCallStackDepthParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setAsyncCallStackDepth', callback?: (err: Error | null) => void): void; - /** - * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. - * @experimental - */ - post( - method: 'Debugger.setBlackboxPatterns', - params?: Debugger.SetBlackboxPatternsParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setBlackboxPatterns', callback?: (err: Error | null) => void): void; - /** - * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted. - * @experimental - */ - post( - method: 'Debugger.setBlackboxedRanges', - params?: Debugger.SetBlackboxedRangesParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Debugger.setBlackboxedRanges', callback?: (err: Error | null) => void): void; - /** - * Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification. - */ - post(method: 'Console.enable', callback?: (err: Error | null) => void): void; - /** - * Disables console domain, prevents further console messages from being reported to the client. - */ - post(method: 'Console.disable', callback?: (err: Error | null) => void): void; - /** - * Does nothing. - */ - post(method: 'Console.clearMessages', callback?: (err: Error | null) => void): void; - post(method: 'Profiler.enable', callback?: (err: Error | null) => void): void; - post(method: 'Profiler.disable', callback?: (err: Error | null) => void): void; - /** - * Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. - */ - post( - method: 'Profiler.setSamplingInterval', - params?: Profiler.SetSamplingIntervalParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Profiler.setSamplingInterval', callback?: (err: Error | null) => void): void; - post(method: 'Profiler.start', callback?: (err: Error | null) => void): void; - post(method: 'Profiler.stop', callback?: (err: Error | null, params: Profiler.StopReturnType) => void): void; - /** - * Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters. - */ - post( - method: 'Profiler.startPreciseCoverage', - params?: Profiler.StartPreciseCoverageParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'Profiler.startPreciseCoverage', callback?: (err: Error | null) => void): void; - /** - * Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code. - */ - post(method: 'Profiler.stopPreciseCoverage', callback?: (err: Error | null) => void): void; - /** - * Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started. - */ - post( - method: 'Profiler.takePreciseCoverage', - callback?: (err: Error | null, params: Profiler.TakePreciseCoverageReturnType) => void, - ): void; - /** - * Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection. - */ - post( - method: 'Profiler.getBestEffortCoverage', - callback?: (err: Error | null, params: Profiler.GetBestEffortCoverageReturnType) => void, - ): void; - /** - * Enable type profile. - * @experimental - */ - post(method: 'Profiler.startTypeProfile', callback?: (err: Error | null) => void): void; - /** - * Disable type profile. Disabling releases type profile data collected so far. - * @experimental - */ - post(method: 'Profiler.stopTypeProfile', callback?: (err: Error | null) => void): void; - /** - * Collect type profile. - * @experimental - */ - post( - method: 'Profiler.takeTypeProfile', - callback?: (err: Error | null, params: Profiler.TakeTypeProfileReturnType) => void, - ): void; - post(method: 'HeapProfiler.enable', callback?: (err: Error | null) => void): void; - post(method: 'HeapProfiler.disable', callback?: (err: Error | null) => void): void; - post( - method: 'HeapProfiler.startTrackingHeapObjects', - params?: HeapProfiler.StartTrackingHeapObjectsParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'HeapProfiler.startTrackingHeapObjects', callback?: (err: Error | null) => void): void; - post( - method: 'HeapProfiler.stopTrackingHeapObjects', - params?: HeapProfiler.StopTrackingHeapObjectsParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'HeapProfiler.stopTrackingHeapObjects', callback?: (err: Error | null) => void): void; - post( - method: 'HeapProfiler.takeHeapSnapshot', - params?: HeapProfiler.TakeHeapSnapshotParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'HeapProfiler.takeHeapSnapshot', callback?: (err: Error | null) => void): void; - post(method: 'HeapProfiler.collectGarbage', callback?: (err: Error | null) => void): void; - post( - method: 'HeapProfiler.getObjectByHeapObjectId', - params?: HeapProfiler.GetObjectByHeapObjectIdParameterType, - callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, - ): void; - post( - method: 'HeapProfiler.getObjectByHeapObjectId', - callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, - ): void; - /** - * Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). - */ - post( - method: 'HeapProfiler.addInspectedHeapObject', - params?: HeapProfiler.AddInspectedHeapObjectParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'HeapProfiler.addInspectedHeapObject', callback?: (err: Error | null) => void): void; - post( - method: 'HeapProfiler.getHeapObjectId', - params?: HeapProfiler.GetHeapObjectIdParameterType, - callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, - ): void; - post( - method: 'HeapProfiler.getHeapObjectId', - callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, - ): void; - post( - method: 'HeapProfiler.startSampling', - params?: HeapProfiler.StartSamplingParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'HeapProfiler.startSampling', callback?: (err: Error | null) => void): void; - post( - method: 'HeapProfiler.stopSampling', - callback?: (err: Error | null, params: HeapProfiler.StopSamplingReturnType) => void, - ): void; - post( - method: 'HeapProfiler.getSamplingProfile', - callback?: (err: Error | null, params: HeapProfiler.GetSamplingProfileReturnType) => void, - ): void; - /** - * Gets supported tracing categories. - */ - post( - method: 'NodeTracing.getCategories', - callback?: (err: Error | null, params: NodeTracing.GetCategoriesReturnType) => void, - ): void; - /** - * Start trace events collection. - */ - post( - method: 'NodeTracing.start', - params?: NodeTracing.StartParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'NodeTracing.start', callback?: (err: Error | null) => void): void; - /** - * Stop trace events collection. Remaining collected events will be sent as a sequence of - * dataCollected events followed by tracingComplete event. - */ - post(method: 'NodeTracing.stop', callback?: (err: Error | null) => void): void; - /** - * Sends protocol message over session with given id. - */ - post( - method: 'NodeWorker.sendMessageToWorker', - params?: NodeWorker.SendMessageToWorkerParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'NodeWorker.sendMessageToWorker', callback?: (err: Error | null) => void): void; - /** - * Instructs the inspector to attach to running workers. Will also attach to new workers - * as they start - */ - post( - method: 'NodeWorker.enable', - params?: NodeWorker.EnableParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'NodeWorker.enable', callback?: (err: Error | null) => void): void; - /** - * Detaches from all running workers and disables attaching to new workers as they are started. - */ - post(method: 'NodeWorker.disable', callback?: (err: Error | null) => void): void; - /** - * Detached from the worker with given sessionId. - */ - post( - method: 'NodeWorker.detach', - params?: NodeWorker.DetachParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void; - /** - * Enable the `NodeRuntime.waitingForDisconnect`. - */ - post( - method: 'NodeRuntime.notifyWhenWaitingForDisconnect', - params?: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType, - callback?: (err: Error | null) => void, - ): void; - post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', callback?: (err: Error | null) => void): void; - // Events - addListener(event: string, listener: (...args: any[]) => void): this; - /** - * Emitted when any notification from the V8 Inspector is received. - */ - addListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; - /** - * Issued when new execution context is created. - */ - addListener( - event: 'Runtime.executionContextCreated', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when execution context is destroyed. - */ - addListener( - event: 'Runtime.executionContextDestroyed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when all executionContexts were cleared in browser - */ - addListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; - /** - * Issued when exception was thrown and unhandled. - */ - addListener( - event: 'Runtime.exceptionThrown', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when unhandled exception was revoked. - */ - addListener( - event: 'Runtime.exceptionRevoked', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when console API was called. - */ - addListener( - event: 'Runtime.consoleAPICalled', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when object should be inspected (for example, as a result of inspect() command line API call). - */ - addListener( - event: 'Runtime.inspectRequested', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. - */ - addListener( - event: 'Debugger.scriptParsed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine fails to parse the script. - */ - addListener( - event: 'Debugger.scriptFailedToParse', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when breakpoint is resolved to an actual script and location. - */ - addListener( - event: 'Debugger.breakpointResolved', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. - */ - addListener( - event: 'Debugger.paused', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine resumed execution. - */ - addListener(event: 'Debugger.resumed', listener: () => void): this; - /** - * Issued when new console message is added. - */ - addListener( - event: 'Console.messageAdded', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Sent when new profile recording is started using console.profile() call. - */ - addListener( - event: 'Profiler.consoleProfileStarted', - listener: (message: InspectorNotification) => void, - ): this; - addListener( - event: 'Profiler.consoleProfileFinished', - listener: (message: InspectorNotification) => void, - ): this; - addListener( - event: 'HeapProfiler.addHeapSnapshotChunk', - listener: (message: InspectorNotification) => void, - ): this; - addListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; - addListener( - event: 'HeapProfiler.reportHeapSnapshotProgress', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. - */ - addListener( - event: 'HeapProfiler.lastSeenObjectId', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend may send update for one or more fragments - */ - addListener( - event: 'HeapProfiler.heapStatsUpdate', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Contains an bucket of collected trace events. - */ - addListener( - event: 'NodeTracing.dataCollected', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Signals that tracing is stopped and there is no trace buffers pending flush, all data were - * delivered via dataCollected events. - */ - addListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; - /** - * Issued when attached to a worker. - */ - addListener( - event: 'NodeWorker.attachedToWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when detached from the worker. - */ - addListener( - event: 'NodeWorker.detachedFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Notifies about a new protocol message received from the session - * (session ID is provided in attachedToWorker notification). - */ - addListener( - event: 'NodeWorker.receivedMessageFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * This event is fired instead of `Runtime.executionContextDestroyed` when - * enabled. - * It is fired when the Node process finished all code execution and is - * waiting for all frontends to disconnect. - */ - addListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; - emit(event: string | symbol, ...args: any[]): boolean; - emit(event: 'inspectorNotification', message: InspectorNotification<{}>): boolean; - emit( - event: 'Runtime.executionContextCreated', - message: InspectorNotification, - ): boolean; - emit( - event: 'Runtime.executionContextDestroyed', - message: InspectorNotification, - ): boolean; - emit(event: 'Runtime.executionContextsCleared'): boolean; - emit( - event: 'Runtime.exceptionThrown', - message: InspectorNotification, - ): boolean; - emit( - event: 'Runtime.exceptionRevoked', - message: InspectorNotification, - ): boolean; - emit( - event: 'Runtime.consoleAPICalled', - message: InspectorNotification, - ): boolean; - emit( - event: 'Runtime.inspectRequested', - message: InspectorNotification, - ): boolean; - emit(event: 'Debugger.scriptParsed', message: InspectorNotification): boolean; - emit( - event: 'Debugger.scriptFailedToParse', - message: InspectorNotification, - ): boolean; - emit( - event: 'Debugger.breakpointResolved', - message: InspectorNotification, - ): boolean; - emit(event: 'Debugger.paused', message: InspectorNotification): boolean; - emit(event: 'Debugger.resumed'): boolean; - emit(event: 'Console.messageAdded', message: InspectorNotification): boolean; - emit( - event: 'Profiler.consoleProfileStarted', - message: InspectorNotification, - ): boolean; - emit( - event: 'Profiler.consoleProfileFinished', - message: InspectorNotification, - ): boolean; - emit( - event: 'HeapProfiler.addHeapSnapshotChunk', - message: InspectorNotification, - ): boolean; - emit(event: 'HeapProfiler.resetProfiles'): boolean; - emit( - event: 'HeapProfiler.reportHeapSnapshotProgress', - message: InspectorNotification, - ): boolean; - emit( - event: 'HeapProfiler.lastSeenObjectId', - message: InspectorNotification, - ): boolean; - emit( - event: 'HeapProfiler.heapStatsUpdate', - message: InspectorNotification, - ): boolean; - emit( - event: 'NodeTracing.dataCollected', - message: InspectorNotification, - ): boolean; - emit(event: 'NodeTracing.tracingComplete'): boolean; - emit( - event: 'NodeWorker.attachedToWorker', - message: InspectorNotification, - ): boolean; - emit( - event: 'NodeWorker.detachedFromWorker', - message: InspectorNotification, - ): boolean; - emit( - event: 'NodeWorker.receivedMessageFromWorker', - message: InspectorNotification, - ): boolean; - emit(event: 'NodeRuntime.waitingForDisconnect'): boolean; - on(event: string, listener: (...args: any[]) => void): this; - /** - * Emitted when any notification from the V8 Inspector is received. - */ - on(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; - /** - * Issued when new execution context is created. - */ - on( - event: 'Runtime.executionContextCreated', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when execution context is destroyed. - */ - on( - event: 'Runtime.executionContextDestroyed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when all executionContexts were cleared in browser - */ - on(event: 'Runtime.executionContextsCleared', listener: () => void): this; - /** - * Issued when exception was thrown and unhandled. - */ - on( - event: 'Runtime.exceptionThrown', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when unhandled exception was revoked. - */ - on( - event: 'Runtime.exceptionRevoked', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when console API was called. - */ - on( - event: 'Runtime.consoleAPICalled', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when object should be inspected (for example, as a result of inspect() command line API call). - */ - on( - event: 'Runtime.inspectRequested', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. - */ - on( - event: 'Debugger.scriptParsed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine fails to parse the script. - */ - on( - event: 'Debugger.scriptFailedToParse', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when breakpoint is resolved to an actual script and location. - */ - on( - event: 'Debugger.breakpointResolved', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. - */ - on( - event: 'Debugger.paused', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine resumed execution. - */ - on(event: 'Debugger.resumed', listener: () => void): this; - /** - * Issued when new console message is added. - */ - on( - event: 'Console.messageAdded', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Sent when new profile recording is started using console.profile() call. - */ - on( - event: 'Profiler.consoleProfileStarted', - listener: (message: InspectorNotification) => void, - ): this; - on( - event: 'Profiler.consoleProfileFinished', - listener: (message: InspectorNotification) => void, - ): this; - on( - event: 'HeapProfiler.addHeapSnapshotChunk', - listener: (message: InspectorNotification) => void, - ): this; - on(event: 'HeapProfiler.resetProfiles', listener: () => void): this; - on( - event: 'HeapProfiler.reportHeapSnapshotProgress', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. - */ - on( - event: 'HeapProfiler.lastSeenObjectId', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend may send update for one or more fragments - */ - on( - event: 'HeapProfiler.heapStatsUpdate', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Contains an bucket of collected trace events. - */ - on( - event: 'NodeTracing.dataCollected', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Signals that tracing is stopped and there is no trace buffers pending flush, all data were - * delivered via dataCollected events. - */ - on(event: 'NodeTracing.tracingComplete', listener: () => void): this; - /** - * Issued when attached to a worker. - */ - on( - event: 'NodeWorker.attachedToWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when detached from the worker. - */ - on( - event: 'NodeWorker.detachedFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Notifies about a new protocol message received from the session - * (session ID is provided in attachedToWorker notification). - */ - on( - event: 'NodeWorker.receivedMessageFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * This event is fired instead of `Runtime.executionContextDestroyed` when - * enabled. - * It is fired when the Node process finished all code execution and is - * waiting for all frontends to disconnect. - */ - on(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; - once(event: string, listener: (...args: any[]) => void): this; - /** - * Emitted when any notification from the V8 Inspector is received. - */ - once(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; - /** - * Issued when new execution context is created. - */ - once( - event: 'Runtime.executionContextCreated', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when execution context is destroyed. - */ - once( - event: 'Runtime.executionContextDestroyed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when all executionContexts were cleared in browser - */ - once(event: 'Runtime.executionContextsCleared', listener: () => void): this; - /** - * Issued when exception was thrown and unhandled. - */ - once( - event: 'Runtime.exceptionThrown', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when unhandled exception was revoked. - */ - once( - event: 'Runtime.exceptionRevoked', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when console API was called. - */ - once( - event: 'Runtime.consoleAPICalled', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when object should be inspected (for example, as a result of inspect() command line API call). - */ - once( - event: 'Runtime.inspectRequested', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. - */ - once( - event: 'Debugger.scriptParsed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine fails to parse the script. - */ - once( - event: 'Debugger.scriptFailedToParse', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when breakpoint is resolved to an actual script and location. - */ - once( - event: 'Debugger.breakpointResolved', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. - */ - once( - event: 'Debugger.paused', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine resumed execution. - */ - once(event: 'Debugger.resumed', listener: () => void): this; - /** - * Issued when new console message is added. - */ - once( - event: 'Console.messageAdded', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Sent when new profile recording is started using console.profile() call. - */ - once( - event: 'Profiler.consoleProfileStarted', - listener: (message: InspectorNotification) => void, - ): this; - once( - event: 'Profiler.consoleProfileFinished', - listener: (message: InspectorNotification) => void, - ): this; - once( - event: 'HeapProfiler.addHeapSnapshotChunk', - listener: (message: InspectorNotification) => void, - ): this; - once(event: 'HeapProfiler.resetProfiles', listener: () => void): this; - once( - event: 'HeapProfiler.reportHeapSnapshotProgress', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. - */ - once( - event: 'HeapProfiler.lastSeenObjectId', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend may send update for one or more fragments - */ - once( - event: 'HeapProfiler.heapStatsUpdate', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Contains an bucket of collected trace events. - */ - once( - event: 'NodeTracing.dataCollected', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Signals that tracing is stopped and there is no trace buffers pending flush, all data were - * delivered via dataCollected events. - */ - once(event: 'NodeTracing.tracingComplete', listener: () => void): this; - /** - * Issued when attached to a worker. - */ - once( - event: 'NodeWorker.attachedToWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when detached from the worker. - */ - once( - event: 'NodeWorker.detachedFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Notifies about a new protocol message received from the session - * (session ID is provided in attachedToWorker notification). - */ - once( - event: 'NodeWorker.receivedMessageFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * This event is fired instead of `Runtime.executionContextDestroyed` when - * enabled. - * It is fired when the Node process finished all code execution and is - * waiting for all frontends to disconnect. - */ - once(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; - prependListener(event: string, listener: (...args: any[]) => void): this; - /** - * Emitted when any notification from the V8 Inspector is received. - */ - prependListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; - /** - * Issued when new execution context is created. - */ - prependListener( - event: 'Runtime.executionContextCreated', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when execution context is destroyed. - */ - prependListener( - event: 'Runtime.executionContextDestroyed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when all executionContexts were cleared in browser - */ - prependListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; - /** - * Issued when exception was thrown and unhandled. - */ - prependListener( - event: 'Runtime.exceptionThrown', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when unhandled exception was revoked. - */ - prependListener( - event: 'Runtime.exceptionRevoked', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when console API was called. - */ - prependListener( - event: 'Runtime.consoleAPICalled', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when object should be inspected (for example, as a result of inspect() command line API call). - */ - prependListener( - event: 'Runtime.inspectRequested', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. - */ - prependListener( - event: 'Debugger.scriptParsed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine fails to parse the script. - */ - prependListener( - event: 'Debugger.scriptFailedToParse', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when breakpoint is resolved to an actual script and location. - */ - prependListener( - event: 'Debugger.breakpointResolved', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. - */ - prependListener( - event: 'Debugger.paused', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine resumed execution. - */ - prependListener(event: 'Debugger.resumed', listener: () => void): this; - /** - * Issued when new console message is added. - */ - prependListener( - event: 'Console.messageAdded', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Sent when new profile recording is started using console.profile() call. - */ - prependListener( - event: 'Profiler.consoleProfileStarted', - listener: (message: InspectorNotification) => void, - ): this; - prependListener( - event: 'Profiler.consoleProfileFinished', - listener: (message: InspectorNotification) => void, - ): this; - prependListener( - event: 'HeapProfiler.addHeapSnapshotChunk', - listener: (message: InspectorNotification) => void, - ): this; - prependListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; - prependListener( - event: 'HeapProfiler.reportHeapSnapshotProgress', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. - */ - prependListener( - event: 'HeapProfiler.lastSeenObjectId', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend may send update for one or more fragments - */ - prependListener( - event: 'HeapProfiler.heapStatsUpdate', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Contains an bucket of collected trace events. - */ - prependListener( - event: 'NodeTracing.dataCollected', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Signals that tracing is stopped and there is no trace buffers pending flush, all data were - * delivered via dataCollected events. - */ - prependListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; - /** - * Issued when attached to a worker. - */ - prependListener( - event: 'NodeWorker.attachedToWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when detached from the worker. - */ - prependListener( - event: 'NodeWorker.detachedFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Notifies about a new protocol message received from the session - * (session ID is provided in attachedToWorker notification). - */ - prependListener( - event: 'NodeWorker.receivedMessageFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * This event is fired instead of `Runtime.executionContextDestroyed` when - * enabled. - * It is fired when the Node process finished all code execution and is - * waiting for all frontends to disconnect. - */ - prependListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; - prependOnceListener(event: string, listener: (...args: any[]) => void): this; - /** - * Emitted when any notification from the V8 Inspector is received. - */ - prependOnceListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; - /** - * Issued when new execution context is created. - */ - prependOnceListener( - event: 'Runtime.executionContextCreated', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when execution context is destroyed. - */ - prependOnceListener( - event: 'Runtime.executionContextDestroyed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when all executionContexts were cleared in browser - */ - prependOnceListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; - /** - * Issued when exception was thrown and unhandled. - */ - prependOnceListener( - event: 'Runtime.exceptionThrown', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when unhandled exception was revoked. - */ - prependOnceListener( - event: 'Runtime.exceptionRevoked', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when console API was called. - */ - prependOnceListener( - event: 'Runtime.consoleAPICalled', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when object should be inspected (for example, as a result of inspect() command line API call). - */ - prependOnceListener( - event: 'Runtime.inspectRequested', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. - */ - prependOnceListener( - event: 'Debugger.scriptParsed', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when virtual machine fails to parse the script. - */ - prependOnceListener( - event: 'Debugger.scriptFailedToParse', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when breakpoint is resolved to an actual script and location. - */ - prependOnceListener( - event: 'Debugger.breakpointResolved', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. - */ - prependOnceListener( - event: 'Debugger.paused', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Fired when the virtual machine resumed execution. - */ - prependOnceListener(event: 'Debugger.resumed', listener: () => void): this; - /** - * Issued when new console message is added. - */ - prependOnceListener( - event: 'Console.messageAdded', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Sent when new profile recording is started using console.profile() call. - */ - prependOnceListener( - event: 'Profiler.consoleProfileStarted', - listener: (message: InspectorNotification) => void, - ): this; - prependOnceListener( - event: 'Profiler.consoleProfileFinished', - listener: (message: InspectorNotification) => void, - ): this; - prependOnceListener( - event: 'HeapProfiler.addHeapSnapshotChunk', - listener: (message: InspectorNotification) => void, - ): this; - prependOnceListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; - prependOnceListener( - event: 'HeapProfiler.reportHeapSnapshotProgress', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. - */ - prependOnceListener( - event: 'HeapProfiler.lastSeenObjectId', - listener: (message: InspectorNotification) => void, - ): this; - /** - * If heap objects tracking has been started then backend may send update for one or more fragments - */ - prependOnceListener( - event: 'HeapProfiler.heapStatsUpdate', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Contains an bucket of collected trace events. - */ - prependOnceListener( - event: 'NodeTracing.dataCollected', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Signals that tracing is stopped and there is no trace buffers pending flush, all data were - * delivered via dataCollected events. - */ - prependOnceListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; - /** - * Issued when attached to a worker. - */ - prependOnceListener( - event: 'NodeWorker.attachedToWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Issued when detached from the worker. - */ - prependOnceListener( - event: 'NodeWorker.detachedFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * Notifies about a new protocol message received from the session - * (session ID is provided in attachedToWorker notification). - */ - prependOnceListener( - event: 'NodeWorker.receivedMessageFromWorker', - listener: (message: InspectorNotification) => void, - ): this; - /** - * This event is fired instead of `Runtime.executionContextDestroyed` when - * enabled. - * It is fired when the Node process finished all code execution and is - * waiting for all frontends to disconnect. - */ - prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; - } - /** - * Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has - * started. - * - * If wait is `true`, will block until a client has connected to the inspect port - * and flow control has been passed to the debugger client. - * - * See the `security warning` regarding the `host`parameter usage. - * @param [port='what was specified on the CLI'] Port to listen on for inspector connections. Optional. - * @param [host='what was specified on the CLI'] Host to listen on for inspector connections. Optional. - * @param [wait=false] Block until a client has connected. Optional. - */ - function open(port?: number, host?: string, wait?: boolean): void; - /** - * Deactivate the inspector. Blocks until there are no active connections. - */ - function close(): void; - /** - * Return the URL of the active inspector, or `undefined` if there is none. - * - * ```console - * $ node --inspect -p 'inspector.url()' - * Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 - * For help, see: https://nodejs.org/en/docs/inspector - * ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 - * - * $ node --inspect=localhost:3000 -p 'inspector.url()' - * Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a - * For help, see: https://nodejs.org/en/docs/inspector - * ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a - * - * $ node -p 'inspector.url()' - * undefined - * ``` - */ - function url(): string | undefined; - /** - * Blocks until a client (existing or connected later) has sent`Runtime.runIfWaitingForDebugger` command. - * - * An exception will be thrown if there is no active inspector. - * @since v12.7.0 - */ - function waitForDebugger(): void; -} -/** - * The inspector module provides an API for interacting with the V8 inspector. - */ -declare module 'node:inspector' { - import inspector = require('inspector'); - export = inspector; -} +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/unified-signatures */ +/* eslint-disable @typescript-eslint/explicit-member-accessibility */ +/* eslint-disable max-lines */ +/* eslint-disable @typescript-eslint/ban-types */ +// Type definitions for inspector + +// These definitions were copied from: +// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/d37bf642ed2f3fe403e405892e2eb4240a191bb0/types/node/inspector.d.ts + +/** + * The `inspector` module provides an API for interacting with the V8 inspector. + * + * It can be accessed using: + * + * ```js + * const inspector = require('inspector'); + * ``` + * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js) + */ +declare module 'inspector' { + import EventEmitter = require('node:events'); + interface InspectorNotification { + method: string; + params: T; + } + namespace Schema { + /** + * Description of the protocol domain. + */ + interface Domain { + /** + * Domain name. + */ + name: string; + /** + * Domain version. + */ + version: string; + } + interface GetDomainsReturnType { + /** + * List of supported domains. + */ + domains: Domain[]; + } + } + namespace Runtime { + /** + * Unique script identifier. + */ + type ScriptId = string; + /** + * Unique object identifier. + */ + type RemoteObjectId = string; + /** + * Primitive value which cannot be JSON-stringified. + */ + type UnserializableValue = string; + /** + * Mirror object referencing original JavaScript object. + */ + interface RemoteObject { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * Object class (constructor) name. Specified for object type values only. + */ + className?: string | undefined; + /** + * Remote object value in case of primitive values or JSON values (if it was requested). + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified does not have value, but gets this property. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * Unique object identifier (for non-primitive values). + */ + objectId?: RemoteObjectId | undefined; + /** + * Preview containing abbreviated property values. Specified for object type values only. + * @experimental + */ + preview?: ObjectPreview | undefined; + /** + * @experimental + */ + customPreview?: CustomPreview | undefined; + } + /** + * @experimental + */ + interface CustomPreview { + header: string; + hasBody: boolean; + formatterObjectId: RemoteObjectId; + bindRemoteObjectFunctionId: RemoteObjectId; + configObjectId?: RemoteObjectId | undefined; + } + /** + * Object containing abbreviated remote object value. + * @experimental + */ + interface ObjectPreview { + /** + * Object type. + */ + type: string; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + /** + * String representation of the object. + */ + description?: string | undefined; + /** + * True iff some of the properties or entries of the original object did not fit. + */ + overflow: boolean; + /** + * List of the properties. + */ + properties: PropertyPreview[]; + /** + * List of the entries. Specified for map and set subtype values only. + */ + entries?: EntryPreview[] | undefined; + } + /** + * @experimental + */ + interface PropertyPreview { + /** + * Property name. + */ + name: string; + /** + * Object type. Accessor means that the property itself is an accessor property. + */ + type: string; + /** + * User-friendly property value string. + */ + value?: string | undefined; + /** + * Nested value preview. + */ + valuePreview?: ObjectPreview | undefined; + /** + * Object subtype hint. Specified for object type values only. + */ + subtype?: string | undefined; + } + /** + * @experimental + */ + interface EntryPreview { + /** + * Preview of the key. Specified for map-like collection entries. + */ + key?: ObjectPreview | undefined; + /** + * Preview of the value. + */ + value: ObjectPreview; + } + /** + * Object property descriptor. + */ + interface PropertyDescriptor { + /** + * Property name or symbol description. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + /** + * True if the value associated with the property may be changed (data descriptors only). + */ + writable?: boolean | undefined; + /** + * A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only). + */ + get?: RemoteObject | undefined; + /** + * A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only). + */ + set?: RemoteObject | undefined; + /** + * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. + */ + configurable: boolean; + /** + * True if this property shows up during enumeration of the properties on the corresponding object. + */ + enumerable: boolean; + /** + * True if the result was thrown during the evaluation. + */ + wasThrown?: boolean | undefined; + /** + * True if the property is owned for the object. + */ + isOwn?: boolean | undefined; + /** + * Property symbol object, if the property is of the symbol type. + */ + symbol?: RemoteObject | undefined; + } + /** + * Object internal property descriptor. This property isn't normally visible in JavaScript code. + */ + interface InternalPropertyDescriptor { + /** + * Conventional property name. + */ + name: string; + /** + * The value associated with the property. + */ + value?: RemoteObject | undefined; + } + /** + * Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified. + */ + interface CallArgument { + /** + * Primitive value or serializable javascript object. + */ + value?: any; + /** + * Primitive value which can not be JSON-stringified. + */ + unserializableValue?: UnserializableValue | undefined; + /** + * Remote object handle. + */ + objectId?: RemoteObjectId | undefined; + } + /** + * Id of an execution context. + */ + type ExecutionContextId = number; + /** + * Description of an isolated world. + */ + interface ExecutionContextDescription { + /** + * Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed. + */ + id: ExecutionContextId; + /** + * Execution context origin. + */ + origin: string; + /** + * Human readable name describing given context. + */ + name: string; + /** + * Embedder-specific auxiliary data. + */ + auxData?: {} | undefined; + } + /** + * Detailed information about exception (or error) that was thrown during script compilation or execution. + */ + interface ExceptionDetails { + /** + * Exception id. + */ + exceptionId: number; + /** + * Exception text, which should be used together with exception object when available. + */ + text: string; + /** + * Line number of the exception location (0-based). + */ + lineNumber: number; + /** + * Column number of the exception location (0-based). + */ + columnNumber: number; + /** + * Script ID of the exception location. + */ + scriptId?: ScriptId | undefined; + /** + * URL of the exception location, to be used when the script was not reported. + */ + url?: string | undefined; + /** + * JavaScript stack trace if available. + */ + stackTrace?: StackTrace | undefined; + /** + * Exception object if available. + */ + exception?: RemoteObject | undefined; + /** + * Identifier of the context where exception happened. + */ + executionContextId?: ExecutionContextId | undefined; + } + /** + * Number of milliseconds since epoch. + */ + type Timestamp = number; + /** + * Stack entry for runtime errors and assertions. + */ + interface CallFrame { + /** + * JavaScript function name. + */ + functionName: string; + /** + * JavaScript script id. + */ + scriptId: ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * JavaScript script line number (0-based). + */ + lineNumber: number; + /** + * JavaScript script column number (0-based). + */ + columnNumber: number; + } + /** + * Call frames for assertions or error messages. + */ + interface StackTrace { + /** + * String label of this stack trace. For async traces this may be a name of the function that initiated the async call. + */ + description?: string | undefined; + /** + * JavaScript function name. + */ + callFrames: CallFrame[]; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + */ + parent?: StackTrace | undefined; + /** + * Asynchronous JavaScript stack trace that preceded this stack, if available. + * @experimental + */ + parentId?: StackTraceId | undefined; + } + /** + * Unique identifier of current debugger. + * @experimental + */ + type UniqueDebuggerId = string; + /** + * If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages. + * @experimental + */ + interface StackTraceId { + id: string; + debuggerId?: UniqueDebuggerId | undefined; + } + interface EvaluateParameterType { + /** + * Expression to evaluate. + */ + expression: string; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + contextId?: ExecutionContextId | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface AwaitPromiseParameterType { + /** + * Identifier of the promise. + */ + promiseObjectId: RemoteObjectId; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + } + interface CallFunctionOnParameterType { + /** + * Declaration of the function to call. + */ + functionDeclaration: string; + /** + * Identifier of the object to call function on. Either objectId or executionContextId should be specified. + */ + objectId?: RemoteObjectId | undefined; + /** + * Call arguments. All call arguments must belong to the same JavaScript world as the target object. + */ + arguments?: CallArgument[] | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should be treated as initiated by user in the UI. + */ + userGesture?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + /** + * Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object. + */ + objectGroup?: string | undefined; + } + interface GetPropertiesParameterType { + /** + * Identifier of the object to return properties for. + */ + objectId: RemoteObjectId; + /** + * If true, returns properties belonging only to the element itself, not to its prototype chain. + */ + ownProperties?: boolean | undefined; + /** + * If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. + * @experimental + */ + accessorPropertiesOnly?: boolean | undefined; + /** + * Whether preview should be generated for the results. + * @experimental + */ + generatePreview?: boolean | undefined; + } + interface ReleaseObjectParameterType { + /** + * Identifier of the object to release. + */ + objectId: RemoteObjectId; + } + interface ReleaseObjectGroupParameterType { + /** + * Symbolic object group name. + */ + objectGroup: string; + } + interface SetCustomObjectFormatterEnabledParameterType { + enabled: boolean; + } + interface CompileScriptParameterType { + /** + * Expression to compile. + */ + expression: string; + /** + * Source url to be set for the script. + */ + sourceURL: string; + /** + * Specifies whether the compiled script should be persisted. + */ + persistScript: boolean; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface RunScriptParameterType { + /** + * Id of the script to run. + */ + scriptId: ScriptId; + /** + * Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page. + */ + executionContextId?: ExecutionContextId | undefined; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Determines whether Command Line API should be available during the evaluation. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object which should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + */ + generatePreview?: boolean | undefined; + /** + * Whether execution should await for resulting value and return once awaited promise is resolved. + */ + awaitPromise?: boolean | undefined; + } + interface QueryObjectsParameterType { + /** + * Identifier of the prototype to return objects for. + */ + prototypeObjectId: RemoteObjectId; + } + interface GlobalLexicalScopeNamesParameterType { + /** + * Specifies in which execution context to lookup global scope variables. + */ + executionContextId?: ExecutionContextId | undefined; + } + interface EvaluateReturnType { + /** + * Evaluation result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface AwaitPromiseReturnType { + /** + * Promise result. Will contain rejected value if promise was rejected. + */ + result: RemoteObject; + /** + * Exception details if stack strace is available. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CallFunctionOnReturnType { + /** + * Call result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface GetPropertiesReturnType { + /** + * Object properties. + */ + result: PropertyDescriptor[]; + /** + * Internal object properties (only of the element itself). + */ + internalProperties?: InternalPropertyDescriptor[] | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface CompileScriptReturnType { + /** + * Id of the script. + */ + scriptId?: ScriptId | undefined; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface RunScriptReturnType { + /** + * Run result. + */ + result: RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: ExceptionDetails | undefined; + } + interface QueryObjectsReturnType { + /** + * Array with objects. + */ + objects: RemoteObject; + } + interface GlobalLexicalScopeNamesReturnType { + names: string[]; + } + interface ExecutionContextCreatedEventDataType { + /** + * A newly created execution context. + */ + context: ExecutionContextDescription; + } + interface ExecutionContextDestroyedEventDataType { + /** + * Id of the destroyed context + */ + executionContextId: ExecutionContextId; + } + interface ExceptionThrownEventDataType { + /** + * Timestamp of the exception. + */ + timestamp: Timestamp; + exceptionDetails: ExceptionDetails; + } + interface ExceptionRevokedEventDataType { + /** + * Reason describing why exception was revoked. + */ + reason: string; + /** + * The id of revoked exception, as reported in exceptionThrown. + */ + exceptionId: number; + } + interface ConsoleAPICalledEventDataType { + /** + * Type of the call. + */ + type: string; + /** + * Call arguments. + */ + args: RemoteObject[]; + /** + * Identifier of the context where the call was made. + */ + executionContextId: ExecutionContextId; + /** + * Call timestamp. + */ + timestamp: Timestamp; + /** + * Stack trace captured when the call was made. + */ + stackTrace?: StackTrace | undefined; + /** + * Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context. + * @experimental + */ + context?: string | undefined; + } + interface InspectRequestedEventDataType { + object: RemoteObject; + hints: {}; + } + } + namespace Debugger { + /** + * Breakpoint identifier. + */ + type BreakpointId = string; + /** + * Call frame identifier. + */ + type CallFrameId = string; + /** + * Location in the source code. + */ + interface Location { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + } + /** + * Location in the source code. + * @experimental + */ + interface ScriptPosition { + lineNumber: number; + columnNumber: number; + } + /** + * JavaScript call frame. Array of call frames form the call stack. + */ + interface CallFrame { + /** + * Call frame identifier. This identifier is only valid while the virtual machine is paused. + */ + callFrameId: CallFrameId; + /** + * Name of the JavaScript function called on this call frame. + */ + functionName: string; + /** + * Location in the source code. + */ + functionLocation?: Location | undefined; + /** + * Location in the source code. + */ + location: Location; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Scope chain for this call frame. + */ + scopeChain: Scope[]; + /** + * this object for this call frame. + */ + this: Runtime.RemoteObject; + /** + * The value being returned, if the function is at return point. + */ + returnValue?: Runtime.RemoteObject | undefined; + } + /** + * Scope description. + */ + interface Scope { + /** + * Scope type. + */ + type: string; + /** + * Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties. + */ + object: Runtime.RemoteObject; + name?: string | undefined; + /** + * Location in the source code where scope starts + */ + startLocation?: Location | undefined; + /** + * Location in the source code where scope ends + */ + endLocation?: Location | undefined; + } + /** + * Search match for resource. + */ + interface SearchMatch { + /** + * Line number in resource content. + */ + lineNumber: number; + /** + * Line with match content. + */ + lineContent: string; + } + interface BreakLocation { + /** + * Script identifier as reported in the Debugger.scriptParsed. + */ + scriptId: Runtime.ScriptId; + /** + * Line number in the script (0-based). + */ + lineNumber: number; + /** + * Column number in the script (0-based). + */ + columnNumber?: number | undefined; + type?: string | undefined; + } + interface SetBreakpointsActiveParameterType { + /** + * New value for breakpoints active state. + */ + active: boolean; + } + interface SetSkipAllPausesParameterType { + /** + * New value for skip pauses state. + */ + skip: boolean; + } + interface SetBreakpointByUrlParameterType { + /** + * Line number to set breakpoint at. + */ + lineNumber: number; + /** + * URL of the resources to set breakpoint on. + */ + url?: string | undefined; + /** + * Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified. + */ + urlRegex?: string | undefined; + /** + * Script hash of the resources to set breakpoint on. + */ + scriptHash?: string | undefined; + /** + * Offset in the line to set breakpoint at. + */ + columnNumber?: number | undefined; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface SetBreakpointParameterType { + /** + * Location to set breakpoint in. + */ + location: Location; + /** + * Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true. + */ + condition?: string | undefined; + } + interface RemoveBreakpointParameterType { + breakpointId: BreakpointId; + } + interface GetPossibleBreakpointsParameterType { + /** + * Start of range to search possible breakpoint locations in. + */ + start: Location; + /** + * End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. + */ + end?: Location | undefined; + /** + * Only consider locations which are in the same (non-nested) function as start. + */ + restrictToFunction?: boolean | undefined; + } + interface ContinueToLocationParameterType { + /** + * Location to continue to. + */ + location: Location; + targetCallFrames?: string | undefined; + } + interface PauseOnAsyncCallParameterType { + /** + * Debugger will pause when async call with given stack trace is started. + */ + parentStackTraceId: Runtime.StackTraceId; + } + interface StepIntoParameterType { + /** + * Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause. + * @experimental + */ + breakOnAsyncCall?: boolean | undefined; + } + interface GetStackTraceParameterType { + stackTraceId: Runtime.StackTraceId; + } + interface SearchInContentParameterType { + /** + * Id of the script to search in. + */ + scriptId: Runtime.ScriptId; + /** + * String to search for. + */ + query: string; + /** + * If true, search is case sensitive. + */ + caseSensitive?: boolean | undefined; + /** + * If true, treats string parameter as regex. + */ + isRegex?: boolean | undefined; + } + interface SetScriptSourceParameterType { + /** + * Id of the script to edit. + */ + scriptId: Runtime.ScriptId; + /** + * New content of the script. + */ + scriptSource: string; + /** + * If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code. + */ + dryRun?: boolean | undefined; + } + interface RestartFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + } + interface GetScriptSourceParameterType { + /** + * Id of the script to get source for. + */ + scriptId: Runtime.ScriptId; + } + interface SetPauseOnExceptionsParameterType { + /** + * Pause on exceptions mode. + */ + state: string; + } + interface EvaluateOnCallFrameParameterType { + /** + * Call frame identifier to evaluate on. + */ + callFrameId: CallFrameId; + /** + * Expression to evaluate. + */ + expression: string; + /** + * String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup). + */ + objectGroup?: string | undefined; + /** + * Specifies whether command line API should be available to the evaluated expression, defaults to false. + */ + includeCommandLineAPI?: boolean | undefined; + /** + * In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. + */ + silent?: boolean | undefined; + /** + * Whether the result is expected to be a JSON object that should be sent by value. + */ + returnByValue?: boolean | undefined; + /** + * Whether preview should be generated for the result. + * @experimental + */ + generatePreview?: boolean | undefined; + /** + * Whether to throw an exception if side effect cannot be ruled out during evaluation. + */ + throwOnSideEffect?: boolean | undefined; + } + interface SetVariableValueParameterType { + /** + * 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually. + */ + scopeNumber: number; + /** + * Variable name. + */ + variableName: string; + /** + * New variable value. + */ + newValue: Runtime.CallArgument; + /** + * Id of callframe that holds variable. + */ + callFrameId: CallFrameId; + } + interface SetReturnValueParameterType { + /** + * New return value. + */ + newValue: Runtime.CallArgument; + } + interface SetAsyncCallStackDepthParameterType { + /** + * Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default). + */ + maxDepth: number; + } + interface SetBlackboxPatternsParameterType { + /** + * Array of regexps that will be used to check script url for blackbox state. + */ + patterns: string[]; + } + interface SetBlackboxedRangesParameterType { + /** + * Id of the script. + */ + scriptId: Runtime.ScriptId; + positions: ScriptPosition[]; + } + interface EnableReturnType { + /** + * Unique identifier of the debugger. + * @experimental + */ + debuggerId: Runtime.UniqueDebuggerId; + } + interface SetBreakpointByUrlReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * List of the locations this breakpoint resolved into upon addition. + */ + locations: Location[]; + } + interface SetBreakpointReturnType { + /** + * Id of the created breakpoint for further reference. + */ + breakpointId: BreakpointId; + /** + * Location this breakpoint resolved into. + */ + actualLocation: Location; + } + interface GetPossibleBreakpointsReturnType { + /** + * List of the possible breakpoint locations. + */ + locations: BreakLocation[]; + } + interface GetStackTraceReturnType { + stackTrace: Runtime.StackTrace; + } + interface SearchInContentReturnType { + /** + * List of search matches. + */ + result: SearchMatch[]; + } + interface SetScriptSourceReturnType { + /** + * New stack trace in case editing has happened while VM was stopped. + */ + callFrames?: CallFrame[] | undefined; + /** + * Whether current call stack was modified after applying the changes. + */ + stackChanged?: boolean | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Exception details if any. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface RestartFrameReturnType { + /** + * New stack trace. + */ + callFrames: CallFrame[]; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + } + interface GetScriptSourceReturnType { + /** + * Script source. + */ + scriptSource: string; + } + interface EvaluateOnCallFrameReturnType { + /** + * Object wrapper for the evaluation result. + */ + result: Runtime.RemoteObject; + /** + * Exception details. + */ + exceptionDetails?: Runtime.ExceptionDetails | undefined; + } + interface ScriptParsedEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * True, if this script is generated as a result of the live edit operation. + * @experimental + */ + isLiveEdit?: boolean | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface ScriptFailedToParseEventDataType { + /** + * Identifier of the script parsed. + */ + scriptId: Runtime.ScriptId; + /** + * URL or name of the script parsed (if any). + */ + url: string; + /** + * Line offset of the script within the resource with given URL (for script tags). + */ + startLine: number; + /** + * Column offset of the script within the resource with given URL. + */ + startColumn: number; + /** + * Last line of the script. + */ + endLine: number; + /** + * Length of the last line of the script. + */ + endColumn: number; + /** + * Specifies script creation context. + */ + executionContextId: Runtime.ExecutionContextId; + /** + * Content hash of the script. + */ + hash: string; + /** + * Embedder-specific auxiliary data. + */ + executionContextAuxData?: {} | undefined; + /** + * URL of source map associated with script (if any). + */ + sourceMapURL?: string | undefined; + /** + * True, if this script has sourceURL. + */ + hasSourceURL?: boolean | undefined; + /** + * True, if this script is ES6 module. + */ + isModule?: boolean | undefined; + /** + * This script length. + */ + length?: number | undefined; + /** + * JavaScript top stack frame of where the script parsed event was triggered if available. + * @experimental + */ + stackTrace?: Runtime.StackTrace | undefined; + } + interface BreakpointResolvedEventDataType { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } + interface PausedEventDataType { + /** + * Call stack the virtual machine stopped on. + */ + callFrames: CallFrame[]; + /** + * Pause reason. + */ + reason: string; + /** + * Object containing break-specific auxiliary properties. + */ + data?: {} | undefined; + /** + * Hit breakpoints IDs + */ + hitBreakpoints?: string[] | undefined; + /** + * Async stack trace, if any. + */ + asyncStackTrace?: Runtime.StackTrace | undefined; + /** + * Async stack trace, if any. + * @experimental + */ + asyncStackTraceId?: Runtime.StackTraceId | undefined; + /** + * Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag. + * @experimental + */ + asyncCallStackTraceId?: Runtime.StackTraceId | undefined; + } + } + namespace Console { + /** + * Console message. + */ + interface ConsoleMessage { + /** + * Message source. + */ + source: string; + /** + * Message severity. + */ + level: string; + /** + * Message text. + */ + text: string; + /** + * URL of the message origin. + */ + url?: string | undefined; + /** + * Line number in the resource that generated this message (1-based). + */ + line?: number | undefined; + /** + * Column number in the resource that generated this message (1-based). + */ + column?: number | undefined; + } + interface MessageAddedEventDataType { + /** + * Console message that has been added. + */ + message: ConsoleMessage; + } + } + namespace Profiler { + /** + * Profile node. Holds callsite information, execution statistics and child nodes. + */ + interface ProfileNode { + /** + * Unique id of the node. + */ + id: number; + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Number of samples where this node was on top of the call stack. + */ + hitCount?: number | undefined; + /** + * Child node ids. + */ + children?: number[] | undefined; + /** + * The reason of being not optimized. The function may be deoptimized or marked as don't optimize. + */ + deoptReason?: string | undefined; + /** + * An array of source position ticks. + */ + positionTicks?: PositionTickInfo[] | undefined; + } + /** + * Profile. + */ + interface Profile { + /** + * The list of profile nodes. First item is the root node. + */ + nodes: ProfileNode[]; + /** + * Profiling start timestamp in microseconds. + */ + startTime: number; + /** + * Profiling end timestamp in microseconds. + */ + endTime: number; + /** + * Ids of samples top nodes. + */ + samples?: number[] | undefined; + /** + * Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime. + */ + timeDeltas?: number[] | undefined; + } + /** + * Specifies a number of samples attributed to a certain source position. + */ + interface PositionTickInfo { + /** + * Source line number (1-based). + */ + line: number; + /** + * Number of samples attributed to the source line. + */ + ticks: number; + } + /** + * Coverage data for a source range. + */ + interface CoverageRange { + /** + * JavaScript script source offset for the range start. + */ + startOffset: number; + /** + * JavaScript script source offset for the range end. + */ + endOffset: number; + /** + * Collected execution count of the source range. + */ + count: number; + } + /** + * Coverage data for a JavaScript function. + */ + interface FunctionCoverage { + /** + * JavaScript function name. + */ + functionName: string; + /** + * Source ranges inside the function with coverage data. + */ + ranges: CoverageRange[]; + /** + * Whether coverage data for this function has block granularity. + */ + isBlockCoverage: boolean; + } + /** + * Coverage data for a JavaScript script. + */ + interface ScriptCoverage { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Functions contained in the script that has coverage data. + */ + functions: FunctionCoverage[]; + } + /** + * Describes a type collected during runtime. + * @experimental + */ + interface TypeObject { + /** + * Name of a type collected with type profiling. + */ + name: string; + } + /** + * Source offset and types for a parameter or return value. + * @experimental + */ + interface TypeProfileEntry { + /** + * Source offset of the parameter or end of function for return values. + */ + offset: number; + /** + * The types for this parameter or return value. + */ + types: TypeObject[]; + } + /** + * Type profile data collected during runtime for a JavaScript script. + * @experimental + */ + interface ScriptTypeProfile { + /** + * JavaScript script id. + */ + scriptId: Runtime.ScriptId; + /** + * JavaScript script name or url. + */ + url: string; + /** + * Type profile entries for parameters and return values of the functions in the script. + */ + entries: TypeProfileEntry[]; + } + interface SetSamplingIntervalParameterType { + /** + * New sampling interval in microseconds. + */ + interval: number; + } + interface StartPreciseCoverageParameterType { + /** + * Collect accurate call counts beyond simple 'covered' or 'not covered'. + */ + callCount?: boolean | undefined; + /** + * Collect block-based coverage. + */ + detailed?: boolean | undefined; + } + interface StopReturnType { + /** + * Recorded profile. + */ + profile: Profile; + } + interface TakePreciseCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface GetBestEffortCoverageReturnType { + /** + * Coverage data for the current isolate. + */ + result: ScriptCoverage[]; + } + interface TakeTypeProfileReturnType { + /** + * Type profile for all scripts since startTypeProfile() was turned on. + */ + result: ScriptTypeProfile[]; + } + interface ConsoleProfileStartedEventDataType { + id: string; + /** + * Location of console.profile(). + */ + location: Debugger.Location; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + interface ConsoleProfileFinishedEventDataType { + id: string; + /** + * Location of console.profileEnd(). + */ + location: Debugger.Location; + profile: Profile; + /** + * Profile title passed as an argument to console.profile(). + */ + title?: string | undefined; + } + } + namespace HeapProfiler { + /** + * Heap snapshot object id. + */ + type HeapSnapshotObjectId = string; + /** + * Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. + */ + interface SamplingHeapProfileNode { + /** + * Function location. + */ + callFrame: Runtime.CallFrame; + /** + * Allocations size in bytes for the node excluding children. + */ + selfSize: number; + /** + * Child nodes. + */ + children: SamplingHeapProfileNode[]; + } + /** + * Profile. + */ + interface SamplingHeapProfile { + head: SamplingHeapProfileNode; + } + interface StartTrackingHeapObjectsParameterType { + trackAllocations?: boolean | undefined; + } + interface StopTrackingHeapObjectsParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped. + */ + reportProgress?: boolean | undefined; + } + interface TakeHeapSnapshotParameterType { + /** + * If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. + */ + reportProgress?: boolean | undefined; + } + interface GetObjectByHeapObjectIdParameterType { + objectId: HeapSnapshotObjectId; + /** + * Symbolic group name that can be used to release multiple objects. + */ + objectGroup?: string | undefined; + } + interface AddInspectedHeapObjectParameterType { + /** + * Heap snapshot object id to be accessible by means of $x command line API. + */ + heapObjectId: HeapSnapshotObjectId; + } + interface GetHeapObjectIdParameterType { + /** + * Identifier of the object to get heap object id for. + */ + objectId: Runtime.RemoteObjectId; + } + interface StartSamplingParameterType { + /** + * Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. + */ + samplingInterval?: number | undefined; + } + interface GetObjectByHeapObjectIdReturnType { + /** + * Evaluation result. + */ + result: Runtime.RemoteObject; + } + interface GetHeapObjectIdReturnType { + /** + * Id of the heap snapshot object corresponding to the passed remote object id. + */ + heapSnapshotObjectId: HeapSnapshotObjectId; + } + interface StopSamplingReturnType { + /** + * Recorded sampling heap profile. + */ + profile: SamplingHeapProfile; + } + interface GetSamplingProfileReturnType { + /** + * Return the sampling profile being collected. + */ + profile: SamplingHeapProfile; + } + interface AddHeapSnapshotChunkEventDataType { + chunk: string; + } + interface ReportHeapSnapshotProgressEventDataType { + done: number; + total: number; + finished?: boolean | undefined; + } + interface LastSeenObjectIdEventDataType { + lastSeenObjectId: number; + timestamp: number; + } + interface HeapStatsUpdateEventDataType { + /** + * An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment. + */ + statsUpdate: number[]; + } + } + namespace NodeTracing { + interface TraceConfig { + /** + * Controls how the trace buffer stores data. + */ + recordMode?: string | undefined; + /** + * Included category filters. + */ + includedCategories: string[]; + } + interface StartParameterType { + traceConfig: TraceConfig; + } + interface GetCategoriesReturnType { + /** + * A list of supported tracing categories. + */ + categories: string[]; + } + interface DataCollectedEventDataType { + value: Array<{}>; + } + } + namespace NodeWorker { + type WorkerID = string; + /** + * Unique identifier of attached debugging session. + */ + type SessionID = string; + interface WorkerInfo { + workerId: WorkerID; + type: string; + title: string; + url: string; + } + interface SendMessageToWorkerParameterType { + message: string; + /** + * Identifier of the session. + */ + sessionId: SessionID; + } + interface EnableParameterType { + /** + * Whether to new workers should be paused until the frontend sends `Runtime.runIfWaitingForDebugger` + * message to run them. + */ + waitForDebuggerOnStart: boolean; + } + interface DetachParameterType { + sessionId: SessionID; + } + interface AttachedToWorkerEventDataType { + /** + * Identifier assigned to the session used to send/receive messages. + */ + sessionId: SessionID; + workerInfo: WorkerInfo; + waitingForDebugger: boolean; + } + interface DetachedFromWorkerEventDataType { + /** + * Detached session identifier. + */ + sessionId: SessionID; + } + interface ReceivedMessageFromWorkerEventDataType { + /** + * Identifier of a session which sends a message. + */ + sessionId: SessionID; + message: string; + } + } + namespace NodeRuntime { + interface NotifyWhenWaitingForDisconnectParameterType { + enabled: boolean; + } + } + /** + * The `inspector.Session` is used for dispatching messages to the V8 inspector + * back-end and receiving message responses and notifications. + */ + class Session extends EventEmitter { + /** + * Create a new instance of the inspector.Session class. + * The inspector session needs to be connected through session.connect() before the messages can be dispatched to the inspector backend. + */ + constructor(); + /** + * Connects a session to the inspector back-end. + * @since v8.0.0 + */ + connect(): void; + /** + * Immediately close the session. All pending message callbacks will be called + * with an error. `session.connect()` will need to be called to be able to send + * messages again. Reconnected session will lose all inspector state, such as + * enabled agents or configured breakpoints. + * @since v8.0.0 + */ + disconnect(): void; + /** + * Posts a message to the inspector back-end. `callback` will be notified when + * a response is received. `callback` is a function that accepts two optional + * arguments: error and message-specific result. + * + * ```js + * session.post('Runtime.evaluate', { expression: '2 + 2' }, + * (error, { result }) => console.log(result)); + * // Output: { type: 'number', value: 4, description: '4' } + * ``` + * + * The latest version of the V8 inspector protocol is published on the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/v8/). + * + * Node.js inspector supports all the Chrome DevTools Protocol domains declared + * by V8\. Chrome DevTools Protocol domain provides an interface for interacting + * with one of the runtime agents used to inspect the application state and listen + * to the run-time events. + * + * ## Example usage + * + * Apart from the debugger, various V8 Profilers are available through the DevTools + * protocol. + * @since v8.0.0 + */ + post(method: string, params?: {}, callback?: (err: Error | null, params?: {}) => void): void; + post(method: string, callback?: (err: Error | null, params?: {}) => void): void; + /** + * Returns supported domains. + */ + post( + method: 'Schema.getDomains', + callback?: (err: Error | null, params: Schema.GetDomainsReturnType) => void, + ): void; + /** + * Evaluates expression on global object. + */ + post( + method: 'Runtime.evaluate', + params?: Runtime.EvaluateParameterType, + callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void, + ): void; + post(method: 'Runtime.evaluate', callback?: (err: Error | null, params: Runtime.EvaluateReturnType) => void): void; + /** + * Add handler to promise with given promise object id. + */ + post( + method: 'Runtime.awaitPromise', + params?: Runtime.AwaitPromiseParameterType, + callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, + ): void; + post( + method: 'Runtime.awaitPromise', + callback?: (err: Error | null, params: Runtime.AwaitPromiseReturnType) => void, + ): void; + /** + * Calls function with given declaration on the given object. Object group of the result is inherited from the target object. + */ + post( + method: 'Runtime.callFunctionOn', + params?: Runtime.CallFunctionOnParameterType, + callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, + ): void; + post( + method: 'Runtime.callFunctionOn', + callback?: (err: Error | null, params: Runtime.CallFunctionOnReturnType) => void, + ): void; + /** + * Returns properties of a given object. Object group of the result is inherited from the target object. + */ + post( + method: 'Runtime.getProperties', + params?: Runtime.GetPropertiesParameterType, + callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, + ): void; + post( + method: 'Runtime.getProperties', + callback?: (err: Error | null, params: Runtime.GetPropertiesReturnType) => void, + ): void; + /** + * Releases remote object with given id. + */ + post( + method: 'Runtime.releaseObject', + params?: Runtime.ReleaseObjectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.releaseObject', callback?: (err: Error | null) => void): void; + /** + * Releases all remote objects that belong to a given group. + */ + post( + method: 'Runtime.releaseObjectGroup', + params?: Runtime.ReleaseObjectGroupParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.releaseObjectGroup', callback?: (err: Error | null) => void): void; + /** + * Tells inspected instance to run if it was waiting for debugger to attach. + */ + post(method: 'Runtime.runIfWaitingForDebugger', callback?: (err: Error | null) => void): void; + /** + * Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context. + */ + post(method: 'Runtime.enable', callback?: (err: Error | null) => void): void; + /** + * Disables reporting of execution contexts creation. + */ + post(method: 'Runtime.disable', callback?: (err: Error | null) => void): void; + /** + * Discards collected exceptions and console API calls. + */ + post(method: 'Runtime.discardConsoleEntries', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post( + method: 'Runtime.setCustomObjectFormatterEnabled', + params?: Runtime.SetCustomObjectFormatterEnabledParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Runtime.setCustomObjectFormatterEnabled', callback?: (err: Error | null) => void): void; + /** + * Compiles expression. + */ + post( + method: 'Runtime.compileScript', + params?: Runtime.CompileScriptParameterType, + callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, + ): void; + post( + method: 'Runtime.compileScript', + callback?: (err: Error | null, params: Runtime.CompileScriptReturnType) => void, + ): void; + /** + * Runs script with given id in a given context. + */ + post( + method: 'Runtime.runScript', + params?: Runtime.RunScriptParameterType, + callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, + ): void; + post( + method: 'Runtime.runScript', + callback?: (err: Error | null, params: Runtime.RunScriptReturnType) => void, + ): void; + post( + method: 'Runtime.queryObjects', + params?: Runtime.QueryObjectsParameterType, + callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, + ): void; + post( + method: 'Runtime.queryObjects', + callback?: (err: Error | null, params: Runtime.QueryObjectsReturnType) => void, + ): void; + /** + * Returns all let, const and class variables from global scope. + */ + post( + method: 'Runtime.globalLexicalScopeNames', + params?: Runtime.GlobalLexicalScopeNamesParameterType, + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, + ): void; + post( + method: 'Runtime.globalLexicalScopeNames', + callback?: (err: Error | null, params: Runtime.GlobalLexicalScopeNamesReturnType) => void, + ): void; + /** + * Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received. + */ + post(method: 'Debugger.enable', callback?: (err: Error | null, params: Debugger.EnableReturnType) => void): void; + /** + * Disables debugger for given page. + */ + post(method: 'Debugger.disable', callback?: (err: Error | null) => void): void; + /** + * Activates / deactivates all breakpoints on the page. + */ + post( + method: 'Debugger.setBreakpointsActive', + params?: Debugger.SetBreakpointsActiveParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBreakpointsActive', callback?: (err: Error | null) => void): void; + /** + * Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + */ + post( + method: 'Debugger.setSkipAllPauses', + params?: Debugger.SetSkipAllPausesParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setSkipAllPauses', callback?: (err: Error | null) => void): void; + /** + * Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads. + */ + post( + method: 'Debugger.setBreakpointByUrl', + params?: Debugger.SetBreakpointByUrlParameterType, + callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, + ): void; + post( + method: 'Debugger.setBreakpointByUrl', + callback?: (err: Error | null, params: Debugger.SetBreakpointByUrlReturnType) => void, + ): void; + /** + * Sets JavaScript breakpoint at a given location. + */ + post( + method: 'Debugger.setBreakpoint', + params?: Debugger.SetBreakpointParameterType, + callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, + ): void; + post( + method: 'Debugger.setBreakpoint', + callback?: (err: Error | null, params: Debugger.SetBreakpointReturnType) => void, + ): void; + /** + * Removes JavaScript breakpoint. + */ + post( + method: 'Debugger.removeBreakpoint', + params?: Debugger.RemoveBreakpointParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.removeBreakpoint', callback?: (err: Error | null) => void): void; + /** + * Returns possible locations for breakpoint. scriptId in start and end range locations should be the same. + */ + post( + method: 'Debugger.getPossibleBreakpoints', + params?: Debugger.GetPossibleBreakpointsParameterType, + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, + ): void; + post( + method: 'Debugger.getPossibleBreakpoints', + callback?: (err: Error | null, params: Debugger.GetPossibleBreakpointsReturnType) => void, + ): void; + /** + * Continues execution until specific location is reached. + */ + post( + method: 'Debugger.continueToLocation', + params?: Debugger.ContinueToLocationParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.continueToLocation', callback?: (err: Error | null) => void): void; + /** + * @experimental + */ + post( + method: 'Debugger.pauseOnAsyncCall', + params?: Debugger.PauseOnAsyncCallParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.pauseOnAsyncCall', callback?: (err: Error | null) => void): void; + /** + * Steps over the statement. + */ + post(method: 'Debugger.stepOver', callback?: (err: Error | null) => void): void; + /** + * Steps into the function call. + */ + post( + method: 'Debugger.stepInto', + params?: Debugger.StepIntoParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.stepInto', callback?: (err: Error | null) => void): void; + /** + * Steps out of the function call. + */ + post(method: 'Debugger.stepOut', callback?: (err: Error | null) => void): void; + /** + * Stops on the next JavaScript statement. + */ + post(method: 'Debugger.pause', callback?: (err: Error | null) => void): void; + /** + * This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called. + * @experimental + */ + post(method: 'Debugger.scheduleStepIntoAsync', callback?: (err: Error | null) => void): void; + /** + * Resumes JavaScript execution. + */ + post(method: 'Debugger.resume', callback?: (err: Error | null) => void): void; + /** + * Returns stack trace with given stackTraceId. + * @experimental + */ + post( + method: 'Debugger.getStackTrace', + params?: Debugger.GetStackTraceParameterType, + callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, + ): void; + post( + method: 'Debugger.getStackTrace', + callback?: (err: Error | null, params: Debugger.GetStackTraceReturnType) => void, + ): void; + /** + * Searches for given string in script content. + */ + post( + method: 'Debugger.searchInContent', + params?: Debugger.SearchInContentParameterType, + callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, + ): void; + post( + method: 'Debugger.searchInContent', + callback?: (err: Error | null, params: Debugger.SearchInContentReturnType) => void, + ): void; + /** + * Edits JavaScript source live. + */ + post( + method: 'Debugger.setScriptSource', + params?: Debugger.SetScriptSourceParameterType, + callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, + ): void; + post( + method: 'Debugger.setScriptSource', + callback?: (err: Error | null, params: Debugger.SetScriptSourceReturnType) => void, + ): void; + /** + * Restarts particular call frame from the beginning. + */ + post( + method: 'Debugger.restartFrame', + params?: Debugger.RestartFrameParameterType, + callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, + ): void; + post( + method: 'Debugger.restartFrame', + callback?: (err: Error | null, params: Debugger.RestartFrameReturnType) => void, + ): void; + /** + * Returns source for the script with given id. + */ + post( + method: 'Debugger.getScriptSource', + params?: Debugger.GetScriptSourceParameterType, + callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, + ): void; + post( + method: 'Debugger.getScriptSource', + callback?: (err: Error | null, params: Debugger.GetScriptSourceReturnType) => void, + ): void; + /** + * Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none. + */ + post( + method: 'Debugger.setPauseOnExceptions', + params?: Debugger.SetPauseOnExceptionsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setPauseOnExceptions', callback?: (err: Error | null) => void): void; + /** + * Evaluates expression on a given call frame. + */ + post( + method: 'Debugger.evaluateOnCallFrame', + params?: Debugger.EvaluateOnCallFrameParameterType, + callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, + ): void; + post( + method: 'Debugger.evaluateOnCallFrame', + callback?: (err: Error | null, params: Debugger.EvaluateOnCallFrameReturnType) => void, + ): void; + /** + * Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually. + */ + post( + method: 'Debugger.setVariableValue', + params?: Debugger.SetVariableValueParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setVariableValue', callback?: (err: Error | null) => void): void; + /** + * Changes return value in top frame. Available only at return break position. + * @experimental + */ + post( + method: 'Debugger.setReturnValue', + params?: Debugger.SetReturnValueParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setReturnValue', callback?: (err: Error | null) => void): void; + /** + * Enables or disables async call stacks tracking. + */ + post( + method: 'Debugger.setAsyncCallStackDepth', + params?: Debugger.SetAsyncCallStackDepthParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setAsyncCallStackDepth', callback?: (err: Error | null) => void): void; + /** + * Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + * @experimental + */ + post( + method: 'Debugger.setBlackboxPatterns', + params?: Debugger.SetBlackboxPatternsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBlackboxPatterns', callback?: (err: Error | null) => void): void; + /** + * Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted. + * @experimental + */ + post( + method: 'Debugger.setBlackboxedRanges', + params?: Debugger.SetBlackboxedRangesParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Debugger.setBlackboxedRanges', callback?: (err: Error | null) => void): void; + /** + * Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification. + */ + post(method: 'Console.enable', callback?: (err: Error | null) => void): void; + /** + * Disables console domain, prevents further console messages from being reported to the client. + */ + post(method: 'Console.disable', callback?: (err: Error | null) => void): void; + /** + * Does nothing. + */ + post(method: 'Console.clearMessages', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.disable', callback?: (err: Error | null) => void): void; + /** + * Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + */ + post( + method: 'Profiler.setSamplingInterval', + params?: Profiler.SetSamplingIntervalParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Profiler.setSamplingInterval', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.start', callback?: (err: Error | null) => void): void; + post(method: 'Profiler.stop', callback?: (err: Error | null, params: Profiler.StopReturnType) => void): void; + /** + * Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters. + */ + post( + method: 'Profiler.startPreciseCoverage', + params?: Profiler.StartPreciseCoverageParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'Profiler.startPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code. + */ + post(method: 'Profiler.stopPreciseCoverage', callback?: (err: Error | null) => void): void; + /** + * Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started. + */ + post( + method: 'Profiler.takePreciseCoverage', + callback?: (err: Error | null, params: Profiler.TakePreciseCoverageReturnType) => void, + ): void; + /** + * Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection. + */ + post( + method: 'Profiler.getBestEffortCoverage', + callback?: (err: Error | null, params: Profiler.GetBestEffortCoverageReturnType) => void, + ): void; + /** + * Enable type profile. + * @experimental + */ + post(method: 'Profiler.startTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Disable type profile. Disabling releases type profile data collected so far. + * @experimental + */ + post(method: 'Profiler.stopTypeProfile', callback?: (err: Error | null) => void): void; + /** + * Collect type profile. + * @experimental + */ + post( + method: 'Profiler.takeTypeProfile', + callback?: (err: Error | null, params: Profiler.TakeTypeProfileReturnType) => void, + ): void; + post(method: 'HeapProfiler.enable', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.disable', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.startTrackingHeapObjects', + params?: HeapProfiler.StartTrackingHeapObjectsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.startTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.stopTrackingHeapObjects', + params?: HeapProfiler.StopTrackingHeapObjectsParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.stopTrackingHeapObjects', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.takeHeapSnapshot', + params?: HeapProfiler.TakeHeapSnapshotParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.takeHeapSnapshot', callback?: (err: Error | null) => void): void; + post(method: 'HeapProfiler.collectGarbage', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + params?: HeapProfiler.GetObjectByHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getObjectByHeapObjectId', + callback?: (err: Error | null, params: HeapProfiler.GetObjectByHeapObjectIdReturnType) => void, + ): void; + /** + * Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). + */ + post( + method: 'HeapProfiler.addInspectedHeapObject', + params?: HeapProfiler.AddInspectedHeapObjectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.addInspectedHeapObject', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.getHeapObjectId', + params?: HeapProfiler.GetHeapObjectIdParameterType, + callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getHeapObjectId', + callback?: (err: Error | null, params: HeapProfiler.GetHeapObjectIdReturnType) => void, + ): void; + post( + method: 'HeapProfiler.startSampling', + params?: HeapProfiler.StartSamplingParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'HeapProfiler.startSampling', callback?: (err: Error | null) => void): void; + post( + method: 'HeapProfiler.stopSampling', + callback?: (err: Error | null, params: HeapProfiler.StopSamplingReturnType) => void, + ): void; + post( + method: 'HeapProfiler.getSamplingProfile', + callback?: (err: Error | null, params: HeapProfiler.GetSamplingProfileReturnType) => void, + ): void; + /** + * Gets supported tracing categories. + */ + post( + method: 'NodeTracing.getCategories', + callback?: (err: Error | null, params: NodeTracing.GetCategoriesReturnType) => void, + ): void; + /** + * Start trace events collection. + */ + post( + method: 'NodeTracing.start', + params?: NodeTracing.StartParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeTracing.start', callback?: (err: Error | null) => void): void; + /** + * Stop trace events collection. Remaining collected events will be sent as a sequence of + * dataCollected events followed by tracingComplete event. + */ + post(method: 'NodeTracing.stop', callback?: (err: Error | null) => void): void; + /** + * Sends protocol message over session with given id. + */ + post( + method: 'NodeWorker.sendMessageToWorker', + params?: NodeWorker.SendMessageToWorkerParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.sendMessageToWorker', callback?: (err: Error | null) => void): void; + /** + * Instructs the inspector to attach to running workers. Will also attach to new workers + * as they start + */ + post( + method: 'NodeWorker.enable', + params?: NodeWorker.EnableParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.enable', callback?: (err: Error | null) => void): void; + /** + * Detaches from all running workers and disables attaching to new workers as they are started. + */ + post(method: 'NodeWorker.disable', callback?: (err: Error | null) => void): void; + /** + * Detached from the worker with given sessionId. + */ + post( + method: 'NodeWorker.detach', + params?: NodeWorker.DetachParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeWorker.detach', callback?: (err: Error | null) => void): void; + /** + * Enable the `NodeRuntime.waitingForDisconnect`. + */ + post( + method: 'NodeRuntime.notifyWhenWaitingForDisconnect', + params?: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType, + callback?: (err: Error | null) => void, + ): void; + post(method: 'NodeRuntime.notifyWhenWaitingForDisconnect', callback?: (err: Error | null) => void): void; + // Events + addListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + addListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + addListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + addListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + addListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + addListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + addListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + addListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + addListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + addListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + addListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + addListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + addListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + addListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + addListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + addListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + addListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + addListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + addListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + addListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + addListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + addListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + addListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + addListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + addListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + addListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + addListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + addListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + emit(event: string | symbol, ...args: any[]): boolean; + emit(event: 'inspectorNotification', message: InspectorNotification<{}>): boolean; + emit( + event: 'Runtime.executionContextCreated', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.executionContextDestroyed', + message: InspectorNotification, + ): boolean; + emit(event: 'Runtime.executionContextsCleared'): boolean; + emit( + event: 'Runtime.exceptionThrown', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.exceptionRevoked', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.consoleAPICalled', + message: InspectorNotification, + ): boolean; + emit( + event: 'Runtime.inspectRequested', + message: InspectorNotification, + ): boolean; + emit(event: 'Debugger.scriptParsed', message: InspectorNotification): boolean; + emit( + event: 'Debugger.scriptFailedToParse', + message: InspectorNotification, + ): boolean; + emit( + event: 'Debugger.breakpointResolved', + message: InspectorNotification, + ): boolean; + emit(event: 'Debugger.paused', message: InspectorNotification): boolean; + emit(event: 'Debugger.resumed'): boolean; + emit(event: 'Console.messageAdded', message: InspectorNotification): boolean; + emit( + event: 'Profiler.consoleProfileStarted', + message: InspectorNotification, + ): boolean; + emit( + event: 'Profiler.consoleProfileFinished', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.addHeapSnapshotChunk', + message: InspectorNotification, + ): boolean; + emit(event: 'HeapProfiler.resetProfiles'): boolean; + emit( + event: 'HeapProfiler.reportHeapSnapshotProgress', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.lastSeenObjectId', + message: InspectorNotification, + ): boolean; + emit( + event: 'HeapProfiler.heapStatsUpdate', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeTracing.dataCollected', + message: InspectorNotification, + ): boolean; + emit(event: 'NodeTracing.tracingComplete'): boolean; + emit( + event: 'NodeWorker.attachedToWorker', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeWorker.detachedFromWorker', + message: InspectorNotification, + ): boolean; + emit( + event: 'NodeWorker.receivedMessageFromWorker', + message: InspectorNotification, + ): boolean; + emit(event: 'NodeRuntime.waitingForDisconnect'): boolean; + on(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + on(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + on( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + on( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + on(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + on( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + on( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + on( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + on( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + on( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + on( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + on( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + on( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + on(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + on( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + on( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + on( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + on( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + on(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + on( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + on( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + on( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + on( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + on(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + on( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + on( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + on( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + on(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + once(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + once(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + once( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + once( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + once(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + once( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + once( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + once( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + once( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + once( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + once( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + once( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + once( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + once(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + once( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + once( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + once( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + once( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + once(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + once( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + once( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + once( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + once( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + once(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + once( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + once( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + once( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + once(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + prependListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + prependListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + prependListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + prependListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + prependListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + prependListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + prependListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + prependListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + /** + * Emitted when any notification from the V8 Inspector is received. + */ + prependOnceListener(event: 'inspectorNotification', listener: (message: InspectorNotification<{}>) => void): this; + /** + * Issued when new execution context is created. + */ + prependOnceListener( + event: 'Runtime.executionContextCreated', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when execution context is destroyed. + */ + prependOnceListener( + event: 'Runtime.executionContextDestroyed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when all executionContexts were cleared in browser + */ + prependOnceListener(event: 'Runtime.executionContextsCleared', listener: () => void): this; + /** + * Issued when exception was thrown and unhandled. + */ + prependOnceListener( + event: 'Runtime.exceptionThrown', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when unhandled exception was revoked. + */ + prependOnceListener( + event: 'Runtime.exceptionRevoked', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when console API was called. + */ + prependOnceListener( + event: 'Runtime.consoleAPICalled', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when object should be inspected (for example, as a result of inspect() command line API call). + */ + prependOnceListener( + event: 'Runtime.inspectRequested', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger. + */ + prependOnceListener( + event: 'Debugger.scriptParsed', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when virtual machine fails to parse the script. + */ + prependOnceListener( + event: 'Debugger.scriptFailedToParse', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when breakpoint is resolved to an actual script and location. + */ + prependOnceListener( + event: 'Debugger.breakpointResolved', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + */ + prependOnceListener( + event: 'Debugger.paused', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Fired when the virtual machine resumed execution. + */ + prependOnceListener(event: 'Debugger.resumed', listener: () => void): this; + /** + * Issued when new console message is added. + */ + prependOnceListener( + event: 'Console.messageAdded', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Sent when new profile recording is started using console.profile() call. + */ + prependOnceListener( + event: 'Profiler.consoleProfileStarted', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener( + event: 'Profiler.consoleProfileFinished', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener( + event: 'HeapProfiler.addHeapSnapshotChunk', + listener: (message: InspectorNotification) => void, + ): this; + prependOnceListener(event: 'HeapProfiler.resetProfiles', listener: () => void): this; + prependOnceListener( + event: 'HeapProfiler.reportHeapSnapshotProgress', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + */ + prependOnceListener( + event: 'HeapProfiler.lastSeenObjectId', + listener: (message: InspectorNotification) => void, + ): this; + /** + * If heap objects tracking has been started then backend may send update for one or more fragments + */ + prependOnceListener( + event: 'HeapProfiler.heapStatsUpdate', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Contains an bucket of collected trace events. + */ + prependOnceListener( + event: 'NodeTracing.dataCollected', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Signals that tracing is stopped and there is no trace buffers pending flush, all data were + * delivered via dataCollected events. + */ + prependOnceListener(event: 'NodeTracing.tracingComplete', listener: () => void): this; + /** + * Issued when attached to a worker. + */ + prependOnceListener( + event: 'NodeWorker.attachedToWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Issued when detached from the worker. + */ + prependOnceListener( + event: 'NodeWorker.detachedFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * Notifies about a new protocol message received from the session + * (session ID is provided in attachedToWorker notification). + */ + prependOnceListener( + event: 'NodeWorker.receivedMessageFromWorker', + listener: (message: InspectorNotification) => void, + ): this; + /** + * This event is fired instead of `Runtime.executionContextDestroyed` when + * enabled. + * It is fired when the Node process finished all code execution and is + * waiting for all frontends to disconnect. + */ + prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this; + } + /** + * Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has + * started. + * + * If wait is `true`, will block until a client has connected to the inspect port + * and flow control has been passed to the debugger client. + * + * See the `security warning` regarding the `host`parameter usage. + * @param [port='what was specified on the CLI'] Port to listen on for inspector connections. Optional. + * @param [host='what was specified on the CLI'] Host to listen on for inspector connections. Optional. + * @param [wait=false] Block until a client has connected. Optional. + */ + function open(port?: number, host?: string, wait?: boolean): void; + /** + * Deactivate the inspector. Blocks until there are no active connections. + */ + function close(): void; + /** + * Return the URL of the active inspector, or `undefined` if there is none. + * + * ```console + * $ node --inspect -p 'inspector.url()' + * Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * For help, see: https://nodejs.org/en/docs/inspector + * ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34 + * + * $ node --inspect=localhost:3000 -p 'inspector.url()' + * Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * For help, see: https://nodejs.org/en/docs/inspector + * ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a + * + * $ node -p 'inspector.url()' + * undefined + * ``` + */ + function url(): string | undefined; + /** + * Blocks until a client (existing or connected later) has sent`Runtime.runIfWaitingForDebugger` command. + * + * An exception will be thrown if there is no active inspector. + * @since v12.7.0 + */ + function waitForDebugger(): void; +} +/** + * The inspector module provides an API for interacting with the V8 inspector. + */ +declare module 'node:inspector' { + import inspector = require('inspector'); + export = inspector; +} diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index c0e3e5a1803d..00b1f9eb0dee 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -1,226 +1,226 @@ -import { parseSemver } from '@sentry/utils'; - -const nodeVersion = parseSemver(process.versions.node); - -if ((nodeVersion.major || 0) < 14) { - throw new Error('The LocalVariables integration requires node.js >= v14'); -} - -import { Event, EventProcessor, Hub, Integration, StackFrame, StackParser } from '@sentry/types'; -import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; -import { LRUMap } from 'lru_map'; - -interface ExceptionData { - description: string; -} - -interface FrameVars { - function: string; - vars?: Record; -} - -/** - * Creates a unique hash from the stack frames - */ -function hashFrames(frames: StackFrame[] | undefined): string | undefined { - if (frames === undefined) { - return; - } - - return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); -} - -/** - * Promise API is available as `Experimental` and in Node 19 only. - * - * Callback-based API is `Stable` since v14 and `Experimental` since v8. - * Because of that, we are creating our own `AsyncSession` class. - * - * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api - * https://nodejs.org/docs/latest-v14.x/api/inspector.html - */ -class AsyncSession extends Session { - public async getProperties(objectId: string): Promise { - return new Promise((resolve, reject) => { - this.post( - 'Runtime.getProperties', - { - objectId, - ownProperties: true, - }, - (err, params) => { - if (err) { - reject(err); - } else { - resolve(params.result); - } - }, - ); - }); - } -} - -/** - * Adds local variables to exception frames - */ -export class LocalVariables implements Integration { - public static id: string = 'LocalVariables'; - - public name: string = LocalVariables.id; - - private readonly _session: AsyncSession; - private readonly _cachedFrameVars: LRUMap> = new LRUMap(50); - // We use the stack parser to create a unique hash from the exception stack trace - // This is used to lookup vars when - private _stackParser: StackParser | undefined; - - public constructor() { - this._session = new AsyncSession(); - this._session.connect(); - this._session.on('Debugger.paused', this._handlePaused.bind(this)); - this._session.post('Debugger.enable'); - // We only care about uncaught exceptions - this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); - } - - /** - * @inheritDoc - */ - public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { - this._stackParser = getCurrentHub().getClient()?.getOptions().stackParser; - - addGlobalEventProcessor(async event => this._addLocalVariables(event)); - } - - /** - * Handle the pause event - */ - private async _handlePaused(event: InspectorNotification): Promise { - // We only care about exceptions for now - if (event.params.reason !== 'exception') { - return; - } - - const exceptionData = event.params?.data as ExceptionData | undefined; - - // event.params.data.description contains the original error.stack - const exceptionHash = - exceptionData?.description && this._stackParser - ? hashFrames(this._stackParser(exceptionData.description, 1)) - : undefined; - - if (exceptionHash == undefined) { - return; - } - - // We add the un-awaited promise to the cache rather than await here otherwise the event processor - // can be called before we're finished getting all the vars - const framesPromise: Promise = Promise.all( - event.params.callFrames.map(async callFrame => { - const localScope = callFrame.scopeChain.find(scope => scope.type === 'local'); - - if (localScope?.object.objectId) { - const vars = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); - - const fn = - callFrame.this.className !== 'global' - ? `${callFrame.this.className}.${callFrame.functionName}` - : callFrame.functionName; - - return { function: fn, vars }; - } - - return { function: callFrame.functionName }; - }), - ); - - this._cachedFrameVars.set(exceptionHash, framesPromise); - } - - /** - * Unrolls all the properties - */ - private async _unrollProps(props: Runtime.PropertyDescriptor[]): Promise> { - const unrolled: Record = {}; - - for (const prop of props) { - if (prop?.value?.objectId && prop?.value.className === 'Array') { - unrolled[prop.name] = await this._unrollArray(prop.value.objectId); - } else if (prop?.value?.objectId && prop?.value?.className === 'Object') { - unrolled[prop.name] = await this._unrollObject(prop.value.objectId); - } else if (prop?.value?.value || prop?.value?.description) { - unrolled[prop.name] = prop.value.value || `<${prop.value.description}>`; - } - } - - return unrolled; - } - - /** - * Unrolls an array property - */ - private async _unrollArray(objectId: string): Promise { - const props = await this._session.getProperties(objectId); - return props - .filter(v => v.name !== 'length') - .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) - .map(v => v?.value?.value); - } - - /** - * Unrolls an object property - */ - private async _unrollObject(objectId: string): Promise> { - const props = await this._session.getProperties(objectId); - return props - .map<[string, unknown]>(v => [v.name, v?.value?.value]) - .reduce((obj, [key, val]) => { - obj[key] = val; - return obj; - }, {} as Record); - } - - /** - * Adds local variables to the exception stack trace frames. - */ - private async _addLocalVariables(event: Event): Promise { - const hash = hashFrames(event?.exception?.values?.[0]?.stacktrace?.frames); - - if (hash === undefined) { - return event; - } - - // Check if we have local variables for an exception that matches the hash - const cachedFrameVars = await this._cachedFrameVars.get(hash); - - if (cachedFrameVars === undefined) { - return event; - } - - const frameCount = event?.exception?.values?.[0]?.stacktrace?.frames?.length || 0; - - for (let i = 0; i < frameCount; i++) { - const frameIndex = frameCount - i - 1; - - // Drop out if we run out of frames to match - if (!event?.exception?.values?.[0]?.stacktrace?.frames?.[frameIndex] || !cachedFrameVars[i]) { - break; - } - - if ( - // We're not interested in frames that are not in_app because the vars are not relevant - event.exception.values[0].stacktrace.frames[frameIndex].in_app === false || - // The function names need to match - event.exception.values[0].stacktrace.frames[frameIndex].function !== cachedFrameVars[i].function || - // We need to have vars to add - cachedFrameVars[i].vars === undefined - ) { - continue; - } - - event.exception.values[0].stacktrace.frames[frameIndex].vars = cachedFrameVars[i].vars; - } - - return event; - } -} +import { parseSemver } from '@sentry/utils'; + +const nodeVersion = parseSemver(process.versions.node); + +if ((nodeVersion.major || 0) < 14) { + throw new Error('The LocalVariables integration requires node.js >= v14'); +} + +import { Event, EventProcessor, Hub, Integration, StackFrame, StackParser } from '@sentry/types'; +import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; +import { LRUMap } from 'lru_map'; + +interface ExceptionData { + description: string; +} + +interface FrameVars { + function: string; + vars?: Record; +} + +/** + * Creates a unique hash from the stack frames + */ +function hashFrames(frames: StackFrame[] | undefined): string | undefined { + if (frames === undefined) { + return; + } + + return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); +} + +/** + * Promise API is available as `Experimental` and in Node 19 only. + * + * Callback-based API is `Stable` since v14 and `Experimental` since v8. + * Because of that, we are creating our own `AsyncSession` class. + * + * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api + * https://nodejs.org/docs/latest-v14.x/api/inspector.html + */ +class AsyncSession extends Session { + public async getProperties(objectId: string): Promise { + return new Promise((resolve, reject) => { + this.post( + 'Runtime.getProperties', + { + objectId, + ownProperties: true, + }, + (err, params) => { + if (err) { + reject(err); + } else { + resolve(params.result); + } + }, + ); + }); + } +} + +/** + * Adds local variables to exception frames + */ +export class LocalVariables implements Integration { + public static id: string = 'LocalVariables'; + + public name: string = LocalVariables.id; + + private readonly _session: AsyncSession; + private readonly _cachedFrameVars: LRUMap> = new LRUMap(50); + // We use the stack parser to create a unique hash from the exception stack trace + // This is used to lookup vars when + private _stackParser: StackParser | undefined; + + public constructor() { + this._session = new AsyncSession(); + this._session.connect(); + this._session.on('Debugger.paused', this._handlePaused.bind(this)); + this._session.post('Debugger.enable'); + // We only care about uncaught exceptions + this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); + } + + /** + * @inheritDoc + */ + public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + this._stackParser = getCurrentHub().getClient()?.getOptions().stackParser; + + addGlobalEventProcessor(async event => this._addLocalVariables(event)); + } + + /** + * Handle the pause event + */ + private async _handlePaused(event: InspectorNotification): Promise { + // We only care about exceptions for now + if (event.params.reason !== 'exception') { + return; + } + + const exceptionData = event.params?.data as ExceptionData | undefined; + + // event.params.data.description contains the original error.stack + const exceptionHash = + exceptionData?.description && this._stackParser + ? hashFrames(this._stackParser(exceptionData.description, 1)) + : undefined; + + if (exceptionHash == undefined) { + return; + } + + // We add the un-awaited promise to the cache rather than await here otherwise the event processor + // can be called before we're finished getting all the vars + const framesPromise: Promise = Promise.all( + event.params.callFrames.map(async callFrame => { + const localScope = callFrame.scopeChain.find(scope => scope.type === 'local'); + + if (localScope?.object.objectId) { + const vars = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); + + const fn = + callFrame.this.className !== 'global' + ? `${callFrame.this.className}.${callFrame.functionName}` + : callFrame.functionName; + + return { function: fn, vars }; + } + + return { function: callFrame.functionName }; + }), + ); + + this._cachedFrameVars.set(exceptionHash, framesPromise); + } + + /** + * Unrolls all the properties + */ + private async _unrollProps(props: Runtime.PropertyDescriptor[]): Promise> { + const unrolled: Record = {}; + + for (const prop of props) { + if (prop?.value?.objectId && prop?.value.className === 'Array') { + unrolled[prop.name] = await this._unrollArray(prop.value.objectId); + } else if (prop?.value?.objectId && prop?.value?.className === 'Object') { + unrolled[prop.name] = await this._unrollObject(prop.value.objectId); + } else if (prop?.value?.value || prop?.value?.description) { + unrolled[prop.name] = prop.value.value || `<${prop.value.description}>`; + } + } + + return unrolled; + } + + /** + * Unrolls an array property + */ + private async _unrollArray(objectId: string): Promise { + const props = await this._session.getProperties(objectId); + return props + .filter(v => v.name !== 'length') + .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) + .map(v => v?.value?.value); + } + + /** + * Unrolls an object property + */ + private async _unrollObject(objectId: string): Promise> { + const props = await this._session.getProperties(objectId); + return props + .map<[string, unknown]>(v => [v.name, v?.value?.value]) + .reduce((obj, [key, val]) => { + obj[key] = val; + return obj; + }, {} as Record); + } + + /** + * Adds local variables to the exception stack trace frames. + */ + private async _addLocalVariables(event: Event): Promise { + const hash = hashFrames(event?.exception?.values?.[0]?.stacktrace?.frames); + + if (hash === undefined) { + return event; + } + + // Check if we have local variables for an exception that matches the hash + const cachedFrameVars = await this._cachedFrameVars.get(hash); + + if (cachedFrameVars === undefined) { + return event; + } + + const frameCount = event?.exception?.values?.[0]?.stacktrace?.frames?.length || 0; + + for (let i = 0; i < frameCount; i++) { + const frameIndex = frameCount - i - 1; + + // Drop out if we run out of frames to match + if (!event?.exception?.values?.[0]?.stacktrace?.frames?.[frameIndex] || !cachedFrameVars[i]) { + break; + } + + if ( + // We're not interested in frames that are not in_app because the vars are not relevant + event.exception.values[0].stacktrace.frames[frameIndex].in_app === false || + // The function names need to match + event.exception.values[0].stacktrace.frames[frameIndex].function !== cachedFrameVars[i].function || + // We need to have vars to add + cachedFrameVars[i].vars === undefined + ) { + continue; + } + + event.exception.values[0].stacktrace.frames[frameIndex].vars = cachedFrameVars[i].vars; + } + + return event; + } +} From 9a8f0dcdbffbc4500ced1b3cc36049ecd03e1722 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Fri, 9 Dec 2022 12:20:29 +0000 Subject: [PATCH 05/19] Improve --- .../node/src/integrations/localvariables.ts | 152 ++++++++++-------- 1 file changed, 88 insertions(+), 64 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 00b1f9eb0dee..3dd2f170b624 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -10,26 +10,6 @@ import { Event, EventProcessor, Hub, Integration, StackFrame, StackParser } from import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; import { LRUMap } from 'lru_map'; -interface ExceptionData { - description: string; -} - -interface FrameVars { - function: string; - vars?: Record; -} - -/** - * Creates a unique hash from the stack frames - */ -function hashFrames(frames: StackFrame[] | undefined): string | undefined { - if (frames === undefined) { - return; - } - - return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); -} - /** * Promise API is available as `Experimental` and in Node 19 only. * @@ -60,26 +40,72 @@ class AsyncSession extends Session { } } +// Add types for the exception event data +type PausedExceptionEvent = Debugger.PausedEventDataType & { + data: { + // This contains error.stack + description: string; + }; +}; + +/** Could this be an anonymous function? */ +function isAnonymous(name: string | undefined): boolean { + return !!name && ['', '?', ''].includes(name); +} + +/** Do the function names appear to match? */ +function functionNamesMatch(a: string | undefined, b: string | undefined): boolean { + return a === b || (isAnonymous(a) && isAnonymous(b)); +} + +/** Creates a unique hash from stack frames */ +function hashFrames(frames: StackFrame[] | undefined): string | undefined { + if (frames === undefined) { + return; + } + + return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); +} + +type HashFromStackFn = (stack: string | undefined) => string | undefined; + +/** + * Creates a function used to hash stack strings + * + * We use the stack parser to create a unique hash from the exception stack trace + * This is used to lookup vars when the exception passes through the event processor + */ +function createHashFn(stackParser: StackParser | undefined): HashFromStackFn { + return (stack: string | undefined) => { + if (stackParser === undefined || stack === undefined) { + return undefined; + } + + return hashFrames(stackParser(stack, 1)); + }; +} + +interface FrameVariables { + function: string; + vars?: Record; +} + /** * Adds local variables to exception frames */ export class LocalVariables implements Integration { public static id: string = 'LocalVariables'; - public name: string = LocalVariables.id; + public readonly name: string = LocalVariables.id; - private readonly _session: AsyncSession; - private readonly _cachedFrameVars: LRUMap> = new LRUMap(50); - // We use the stack parser to create a unique hash from the exception stack trace - // This is used to lookup vars when - private _stackParser: StackParser | undefined; + private readonly _session: AsyncSession = new AsyncSession(); + private readonly _cachedFrames: LRUMap> = new LRUMap(50); public constructor() { - this._session = new AsyncSession(); this._session.connect(); this._session.on('Debugger.paused', this._handlePaused.bind(this)); this._session.post('Debugger.enable'); - // We only care about uncaught exceptions + // We only want to pause on uncaught exceptions this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); } @@ -87,54 +113,51 @@ export class LocalVariables implements Integration { * @inheritDoc */ public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { - this._stackParser = getCurrentHub().getClient()?.getOptions().stackParser; + this._stackHasher = createHashFn(getCurrentHub().getClient()?.getOptions().stackParser); addGlobalEventProcessor(async event => this._addLocalVariables(event)); } + /** + * We use the stack parser to create a unique hash from the exception stack trace + * This is used to lookup vars when + */ + private _stackHasher: HashFromStackFn = _ => undefined; + /** * Handle the pause event */ - private async _handlePaused(event: InspectorNotification): Promise { - // We only care about exceptions for now - if (event.params.reason !== 'exception') { + private async _handlePaused({ + params: { reason, data, callFrames }, + }: InspectorNotification): Promise { + if (reason !== 'exception' && reason !== 'promiseRejection') { return; } - const exceptionData = event.params?.data as ExceptionData | undefined; - - // event.params.data.description contains the original error.stack - const exceptionHash = - exceptionData?.description && this._stackParser - ? hashFrames(this._stackParser(exceptionData.description, 1)) - : undefined; + // data.description contains the original error.stack + const exceptionHash = this._stackHasher(data?.description); if (exceptionHash == undefined) { return; } - // We add the un-awaited promise to the cache rather than await here otherwise the event processor - // can be called before we're finished getting all the vars - const framesPromise: Promise = Promise.all( - event.params.callFrames.map(async callFrame => { - const localScope = callFrame.scopeChain.find(scope => scope.type === 'local'); + const framePromises = callFrames.map(async ({ scopeChain, functionName, this: obj }) => { + const localScope = scopeChain.find(scope => scope.type === 'local'); - if (localScope?.object.objectId) { - const vars = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); + const fn = obj.className !== 'global' ? `${obj.className}.${functionName}` : functionName; - const fn = - callFrame.this.className !== 'global' - ? `${callFrame.this.className}.${callFrame.functionName}` - : callFrame.functionName; + if (localScope?.object.objectId === undefined) { + return { function: fn }; + } - return { function: fn, vars }; - } + const vars = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); - return { function: callFrame.functionName }; - }), - ); + return { function: fn, vars }; + }); - this._cachedFrameVars.set(exceptionHash, framesPromise); + // We add the un-awaited promise to the cache rather than await here otherwise the event processor + // can be called before we're finished getting all the vars + this._cachedFrames.set(exceptionHash, Promise.all(framePromises)); } /** @@ -191,34 +214,35 @@ export class LocalVariables implements Integration { } // Check if we have local variables for an exception that matches the hash - const cachedFrameVars = await this._cachedFrameVars.get(hash); + const cachedFrames = await this._cachedFrames.get(hash); - if (cachedFrameVars === undefined) { + if (cachedFrames === undefined) { return event; } const frameCount = event?.exception?.values?.[0]?.stacktrace?.frames?.length || 0; for (let i = 0; i < frameCount; i++) { + // Sentry frames are already in reverse order const frameIndex = frameCount - i - 1; - // Drop out if we run out of frames to match - if (!event?.exception?.values?.[0]?.stacktrace?.frames?.[frameIndex] || !cachedFrameVars[i]) { + // Drop out if we run out of frames to match up + if (!event?.exception?.values?.[0]?.stacktrace?.frames?.[frameIndex] || !cachedFrames[i]) { break; } if ( + // We need to have vars to add + cachedFrames[i].vars === undefined || // We're not interested in frames that are not in_app because the vars are not relevant event.exception.values[0].stacktrace.frames[frameIndex].in_app === false || // The function names need to match - event.exception.values[0].stacktrace.frames[frameIndex].function !== cachedFrameVars[i].function || - // We need to have vars to add - cachedFrameVars[i].vars === undefined + !functionNamesMatch(event.exception.values[0].stacktrace.frames[frameIndex].function, cachedFrames[i].function) ) { continue; } - event.exception.values[0].stacktrace.frames[frameIndex].vars = cachedFrameVars[i].vars; + event.exception.values[0].stacktrace.frames[frameIndex].vars = cachedFrames[i].vars; } return event; From 726e8742caf77f65950c12c98be9e7ebcaec0c95 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Fri, 9 Dec 2022 12:38:16 +0000 Subject: [PATCH 06/19] Better defaultIntegrations --- packages/node/src/sdk.ts | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index f278ee656dfa..3a08e222e5b9 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -7,7 +7,7 @@ import { Integrations as CoreIntegrations, setHubOnCarrier, } from '@sentry/core'; -import { SessionStatus, StackParser } from '@sentry/types'; +import { Integration, SessionStatus, StackParser } from '@sentry/types'; import { createStackParser, dynamicRequire, @@ -109,29 +109,11 @@ export const defaultIntegrations = [ * * @see {@link NodeOptions} for documentation on configuration options. */ -// eslint-disable-next-line complexity export function init(options: NodeOptions = {}): void { const carrier = getMainCarrier(); const autoloadedIntegrations = carrier.__SENTRY__?.integrations || []; - options.defaultIntegrations = - options.defaultIntegrations === false - ? [] - : [ - ...(Array.isArray(options.defaultIntegrations) ? options.defaultIntegrations : defaultIntegrations), - ...autoloadedIntegrations, - ]; - - const nodeVersion = parseSemver(process.versions.node); - - if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { - const { LocalVariables } = dynamicRequire( - module, - './integrations/localvariables', - ) as typeof import('./integrations/localvariables'); - - options.defaultIntegrations.push(new LocalVariables()); - } + options.defaultIntegrations = getDefaultIntegrations(options, autoloadedIntegrations); if (options.dsn === undefined && process.env.SENTRY_DSN) { options.dsn = process.env.SENTRY_DSN; @@ -186,6 +168,29 @@ export function init(options: NodeOptions = {}): void { } } +function getDefaultIntegrations(options: NodeOptions, autoloadedIntegrations: Integration[]): Integration[] { + const integrations = + options.defaultIntegrations === false + ? [] + : [ + ...(Array.isArray(options.defaultIntegrations) ? options.defaultIntegrations : defaultIntegrations), + ...autoloadedIntegrations, + ]; + + const nodeVersion = parseSemver(process.versions.node); + + if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { + const { LocalVariables } = dynamicRequire( + module, + './integrations/localvariables', + ) as typeof import('./integrations/localvariables'); + + integrations.push(new LocalVariables()); + } + + return integrations; +} + /** * This is the getter for lastEventId. * From d39fe92e811116fa3ed592220c8c24446ce9a6a5 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 12 Dec 2022 15:30:36 +0000 Subject: [PATCH 07/19] Dont check for node version since v8 supports `inspector` --- packages/node/src/integrations/index.ts | 1 + .../node/src/integrations/localvariables.ts | 40 ++++++++--------- packages/node/src/sdk.ts | 45 +++++-------------- 3 files changed, 29 insertions(+), 57 deletions(-) diff --git a/packages/node/src/integrations/index.ts b/packages/node/src/integrations/index.ts index cdb5145b0ea1..167a482e5b5f 100644 --- a/packages/node/src/integrations/index.ts +++ b/packages/node/src/integrations/index.ts @@ -7,3 +7,4 @@ export { Modules } from './modules'; export { ContextLines } from './contextlines'; export { Context } from './context'; export { RequestData } from './requestdata'; +export { LocalVariables } from './localvariables'; diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 3dd2f170b624..e71d714a1700 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -1,15 +1,10 @@ -import { parseSemver } from '@sentry/utils'; - -const nodeVersion = parseSemver(process.versions.node); - -if ((nodeVersion.major || 0) < 14) { - throw new Error('The LocalVariables integration requires node.js >= v14'); -} - -import { Event, EventProcessor, Hub, Integration, StackFrame, StackParser } from '@sentry/types'; +import { getCurrentHub } from '@sentry/core'; +import { Event, EventProcessor, Integration, StackFrame, StackParser } from '@sentry/types'; import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; import { LRUMap } from 'lru_map'; +import { NodeClient } from '../client'; + /** * Promise API is available as `Experimental` and in Node 19 only. * @@ -101,26 +96,27 @@ export class LocalVariables implements Integration { private readonly _session: AsyncSession = new AsyncSession(); private readonly _cachedFrames: LRUMap> = new LRUMap(50); - public constructor() { - this._session.connect(); - this._session.on('Debugger.paused', this._handlePaused.bind(this)); - this._session.post('Debugger.enable'); - // We only want to pause on uncaught exceptions - this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); - } - /** * @inheritDoc */ - public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { - this._stackHasher = createHashFn(getCurrentHub().getClient()?.getOptions().stackParser); - - addGlobalEventProcessor(async event => this._addLocalVariables(event)); + public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void { + const options = getCurrentHub().getClient()?.getOptions(); + + if (options?.includeStackLocals) { + this._stackHasher = createHashFn(options.stackParser); + addGlobalEventProcessor(async event => this._addLocalVariables(event)); + + this._session.connect(); + this._session.on('Debugger.paused', this._handlePaused.bind(this)); + this._session.post('Debugger.enable'); + // We only want to pause on uncaught exceptions + this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); + } } /** * We use the stack parser to create a unique hash from the exception stack trace - * This is used to lookup vars when + * This is used to lookup vars when the event processor is called */ private _stackHasher: HashFromStackFn = _ => undefined; diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index 31b9aa904106..1dc0c968a8f5 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -7,14 +7,12 @@ import { Integrations as CoreIntegrations, setHubOnCarrier, } from '@sentry/core'; -import { Integration, SessionStatus, StackParser } from '@sentry/types'; +import { SessionStatus, StackParser } from '@sentry/types'; import { createStackParser, - dynamicRequire, GLOBAL_OBJ, logger, nodeStackLineParser, - parseSemver, stackParserFromStackParserOptions, } from '@sentry/utils'; import * as domain from 'domain'; @@ -26,6 +24,7 @@ import { ContextLines, Http, LinkedErrors, + LocalVariables, Modules, OnUncaughtException, OnUnhandledRejection, @@ -52,6 +51,7 @@ export const defaultIntegrations = [ new RequestData(), // Misc new LinkedErrors(), + new LocalVariables(), ]; /** @@ -114,15 +114,13 @@ export function init(options: NodeOptions = {}): void { const carrier = getMainCarrier(); const autoloadedIntegrations = carrier.__SENTRY__?.integrations || []; - options.defaultIntegrations = getDefaultIntegrations(options, autoloadedIntegrations); - - const nodeVersion = parseSemver(process.versions.node); - - if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const { LocalVariables } = require('./integrations/localvariables'); - options.defaultIntegrations.push(new LocalVariables()); - } + options.defaultIntegrations = + options.defaultIntegrations === false + ? [] + : [ + ...(Array.isArray(options.defaultIntegrations) ? options.defaultIntegrations : defaultIntegrations), + ...autoloadedIntegrations, + ]; if (options.dsn === undefined && process.env.SENTRY_DSN) { options.dsn = process.env.SENTRY_DSN; @@ -177,29 +175,6 @@ export function init(options: NodeOptions = {}): void { } } -function getDefaultIntegrations(options: NodeOptions, autoloadedIntegrations: Integration[]): Integration[] { - const integrations = - options.defaultIntegrations === false - ? [] - : [ - ...(Array.isArray(options.defaultIntegrations) ? options.defaultIntegrations : defaultIntegrations), - ...autoloadedIntegrations, - ]; - - const nodeVersion = parseSemver(process.versions.node); - - if (options.includeStackLocals && (nodeVersion.major || 0) >= 14) { - const { LocalVariables } = dynamicRequire( - module, - './integrations/localvariables', - ) as typeof import('./integrations/localvariables'); - - integrations.push(new LocalVariables()); - } - - return integrations; -} - /** * This is the getter for lastEventId. * From 65ea4424a999f0ac8971ef1f6e46a66b6b99a8f5 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 12 Dec 2022 15:45:38 +0000 Subject: [PATCH 08/19] Simplify a bit more --- .../node/src/integrations/localvariables.ts | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index e71d714a1700..c2ce2a1fc013 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -62,24 +62,6 @@ function hashFrames(frames: StackFrame[] | undefined): string | undefined { return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); } -type HashFromStackFn = (stack: string | undefined) => string | undefined; - -/** - * Creates a function used to hash stack strings - * - * We use the stack parser to create a unique hash from the exception stack trace - * This is used to lookup vars when the exception passes through the event processor - */ -function createHashFn(stackParser: StackParser | undefined): HashFromStackFn { - return (stack: string | undefined) => { - if (stackParser === undefined || stack === undefined) { - return undefined; - } - - return hashFrames(stackParser(stack, 1)); - }; -} - interface FrameVariables { function: string; vars?: Record; @@ -95,6 +77,7 @@ export class LocalVariables implements Integration { private readonly _session: AsyncSession = new AsyncSession(); private readonly _cachedFrames: LRUMap> = new LRUMap(50); + private _stackParser: StackParser | undefined; /** * @inheritDoc @@ -103,22 +86,29 @@ export class LocalVariables implements Integration { const options = getCurrentHub().getClient()?.getOptions(); if (options?.includeStackLocals) { - this._stackHasher = createHashFn(options.stackParser); - addGlobalEventProcessor(async event => this._addLocalVariables(event)); + this._stackParser = options.stackParser; this._session.connect(); this._session.on('Debugger.paused', this._handlePaused.bind(this)); this._session.post('Debugger.enable'); // We only want to pause on uncaught exceptions this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); + + addGlobalEventProcessor(async event => this._addLocalVariables(event)); } } /** * We use the stack parser to create a unique hash from the exception stack trace - * This is used to lookup vars when the event processor is called + * This is used to lookup vars when the exception passes through the event processor */ - private _stackHasher: HashFromStackFn = _ => undefined; + private _hashFromStack(stack: string | undefined): string | undefined { + if (this._stackParser === undefined || stack === undefined) { + return undefined; + } + + return hashFrames(this._stackParser(stack, 1)); + } /** * Handle the pause event @@ -131,7 +121,7 @@ export class LocalVariables implements Integration { } // data.description contains the original error.stack - const exceptionHash = this._stackHasher(data?.description); + const exceptionHash = this._hashFromStack(data?.description); if (exceptionHash == undefined) { return; @@ -219,7 +209,7 @@ export class LocalVariables implements Integration { const frameCount = event?.exception?.values?.[0]?.stacktrace?.frames?.length || 0; for (let i = 0; i < frameCount; i++) { - // Sentry frames are already in reverse order + // Sentry frames are in reverse order const frameIndex = frameCount - i - 1; // Drop out if we run out of frames to match up From 5e0174bb1db16836eb57e8170145e29c3ffe210a Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 12 Dec 2022 19:21:36 +0000 Subject: [PATCH 09/19] Add some tests --- .../LocalVariables/local-variables.js | 35 ++++++++++++ .../LocalVariables/no-local-variables.js | 34 ++++++++++++ .../suites/public-api/LocalVariables/test.ts | 54 +++++++++++++++++++ .../node/src/integrations/localvariables.ts | 2 +- 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js create mode 100644 packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js create mode 100644 packages/node-integration-tests/suites/public-api/LocalVariables/test.ts diff --git a/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js b/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js new file mode 100644 index 000000000000..10a53ee667a9 --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js @@ -0,0 +1,35 @@ +/* eslint-disable no-unused-vars */ +const Sentry = require('@sentry/node'); + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + includeStackLocals: true, + beforeSend: event => { + // eslint-disable-next-line no-console + console.log(JSON.stringify(event)); + }, +}); + +process.on('uncaughtException', () => { + // do nothing - this will prevent the Error below from closing this process +}); + +class Some { + two(name) { + throw new Error('Enough!'); + } +} + +function one(name) { + const arr = [1, '2', new Date()]; + const obj = { + name, + num: 5, + }; + + const ty = new Some(); + + ty.two(name); +} + +one('some name'); diff --git a/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js b/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js new file mode 100644 index 000000000000..bb292bdc500e --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js @@ -0,0 +1,34 @@ +/* eslint-disable no-unused-vars */ +const Sentry = require('@sentry/node'); + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + beforeSend: event => { + // eslint-disable-next-line no-console + console.log(JSON.stringify(event)); + }, +}); + +process.on('uncaughtException', () => { + // do nothing - this will prevent the Error below from closing this process +}); + +class Some { + two(name) { + throw new Error('Enough!'); + } +} + +function one(name) { + const arr = [1, '2', new Date()]; + const obj = { + name, + num: 5, + }; + + const ty = new Some(); + + ty.two(name); +} + +one('some name'); diff --git a/packages/node-integration-tests/suites/public-api/LocalVariables/test.ts b/packages/node-integration-tests/suites/public-api/LocalVariables/test.ts new file mode 100644 index 000000000000..37f155e534a6 --- /dev/null +++ b/packages/node-integration-tests/suites/public-api/LocalVariables/test.ts @@ -0,0 +1,54 @@ +import { Event } from '@sentry/node'; +import * as childProcess from 'child_process'; +import * as path from 'path'; + +describe('LocalVariables integration', () => { + test('Should not include local variables by default', done => { + expect.assertions(2); + + const testScriptPath = path.resolve(__dirname, 'no-local-variables.js'); + + childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (_, stdout) => { + const event = JSON.parse(stdout) as Event; + + const frames = event.exception?.values?.[0].stacktrace?.frames || []; + const lastFrame = frames[frames.length - 1]; + + expect(lastFrame.vars).toBeUndefined(); + + const penultimateFrame = frames[frames.length - 2]; + + expect(penultimateFrame.vars).toBeUndefined(); + + done(); + }); + }); + + test('Should include local variables when enabled', done => { + expect.assertions(4); + + const testScriptPath = path.resolve(__dirname, 'local-variables.js'); + + childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (_, stdout) => { + const event = JSON.parse(stdout) as Event; + + const frames = event.exception?.values?.[0].stacktrace?.frames || []; + const lastFrame = frames[frames.length - 1]; + + expect(lastFrame.function).toBe('Some.two'); + expect(lastFrame.vars).toEqual({ name: 'some name' }); + + const penultimateFrame = frames[frames.length - 2]; + + expect(penultimateFrame.function).toBe('one'); + expect(penultimateFrame.vars).toEqual({ + name: 'some name', + arr: [1, '2', null], + obj: { name: 'some name', num: 5 }, + ty: '', + }); + + done(); + }); + }); +}); diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index c2ce2a1fc013..bb3cd56a66df 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -45,7 +45,7 @@ type PausedExceptionEvent = Debugger.PausedEventDataType & { /** Could this be an anonymous function? */ function isAnonymous(name: string | undefined): boolean { - return !!name && ['', '?', ''].includes(name); + return name !== undefined && ['', '?', ''].includes(name); } /** Do the function names appear to match? */ From c0f47b6cef33c4d17dbf1e243809f661c8f97897 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 13 Dec 2022 13:11:30 +0000 Subject: [PATCH 10/19] fix for older node versions where we get a __proto__ array property --- .../suites/public-api/LocalVariables/local-variables.js | 2 +- .../suites/public-api/LocalVariables/no-local-variables.js | 2 +- packages/node/src/integrations/localvariables.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js b/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js index 10a53ee667a9..5c03d29146fa 100644 --- a/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js +++ b/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js @@ -21,7 +21,7 @@ class Some { } function one(name) { - const arr = [1, '2', new Date()]; + const arr = [1, '2', null]; const obj = { name, num: 5, diff --git a/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js b/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js index bb292bdc500e..03c9254efea8 100644 --- a/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js +++ b/packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js @@ -20,7 +20,7 @@ class Some { } function one(name) { - const arr = [1, '2', new Date()]; + const arr = [1, '2', null]; const obj = { name, num: 5, diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index bb3cd56a66df..023a3dc2ef5d 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -171,7 +171,7 @@ export class LocalVariables implements Integration { private async _unrollArray(objectId: string): Promise { const props = await this._session.getProperties(objectId); return props - .filter(v => v.name !== 'length') + .filter(v => v.name !== 'length' && !isNaN(parseInt(v.name, 10))) .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) .map(v => v?.value?.value); } From b8479809156c10626f89c453eaa0a582a4004bfe Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 13 Dec 2022 13:28:03 +0000 Subject: [PATCH 11/19] Move option to _experiments --- .../suites/public-api/LocalVariables/local-variables.js | 2 +- packages/node/src/integrations/localvariables.ts | 2 +- packages/node/src/types.ts | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js b/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js index 5c03d29146fa..db24a014c5a2 100644 --- a/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js +++ b/packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js @@ -3,7 +3,7 @@ const Sentry = require('@sentry/node'); Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - includeStackLocals: true, + _experiments: { includeStackLocals: true }, beforeSend: event => { // eslint-disable-next-line no-console console.log(JSON.stringify(event)); diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 023a3dc2ef5d..8a7644350bb8 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -85,7 +85,7 @@ export class LocalVariables implements Integration { public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void { const options = getCurrentHub().getClient()?.getOptions(); - if (options?.includeStackLocals) { + if (options?._experiments?.includeStackLocals) { this._stackParser = options.stackParser; this._session.connect(); diff --git a/packages/node/src/types.ts b/packages/node/src/types.ts index 5dd9f16cddfe..d4ca5dd4900d 100644 --- a/packages/node/src/types.ts +++ b/packages/node/src/types.ts @@ -11,9 +11,6 @@ export interface BaseNodeOptions { /** Sets an optional server name (device name) */ serverName?: string; - /** */ - includeStackLocals?: boolean; - // TODO (v8): Remove this in v8 /** * @deprecated Moved to constructor options of the `Http` integration. From d40235406f74b570c001e9aae5e63e0d80b8d7b2 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 14 Dec 2022 14:50:01 +0000 Subject: [PATCH 12/19] changes from review --- .../node/src/integrations/localvariables.ts | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 8a7644350bb8..2b6bf8cefd76 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -1,10 +1,8 @@ import { getCurrentHub } from '@sentry/core'; -import { Event, EventProcessor, Integration, StackFrame, StackParser } from '@sentry/types'; +import { Event, EventProcessor, Exception, Integration, StackFrame, StackParser } from '@sentry/types'; import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; import { LRUMap } from 'lru_map'; -import { NodeClient } from '../client'; - /** * Promise API is available as `Experimental` and in Node 19 only. * @@ -15,7 +13,7 @@ import { NodeClient } from '../client'; * https://nodejs.org/docs/latest-v14.x/api/inspector.html */ class AsyncSession extends Session { - public async getProperties(objectId: string): Promise { + public getProperties(objectId: string): Promise { return new Promise((resolve, reject) => { this.post( 'Runtime.getProperties', @@ -59,7 +57,8 @@ function hashFrames(frames: StackFrame[] | undefined): string | undefined { return; } - return frames.reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); + // Only hash the 10 most recent frames (ie. the last 10) + return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); } interface FrameVariables { @@ -76,14 +75,14 @@ export class LocalVariables implements Integration { public readonly name: string = LocalVariables.id; private readonly _session: AsyncSession = new AsyncSession(); - private readonly _cachedFrames: LRUMap> = new LRUMap(50); + private readonly _cachedFrames: LRUMap> = new LRUMap(20); private _stackParser: StackParser | undefined; /** * @inheritDoc */ public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void { - const options = getCurrentHub().getClient()?.getOptions(); + const options = getCurrentHub().getClient()?.getOptions(); if (options?._experiments?.includeStackLocals) { this._stackParser = options.stackParser; @@ -130,7 +129,7 @@ export class LocalVariables implements Integration { const framePromises = callFrames.map(async ({ scopeChain, functionName, this: obj }) => { const localScope = scopeChain.find(scope => scope.type === 'local'); - const fn = obj.className !== 'global' ? `${obj.className}.${functionName}` : functionName; + const fn = obj.className === 'global' ? functionName : `${obj.className}.${functionName}`; if (localScope?.object.objectId === undefined) { return { function: fn }; @@ -190,30 +189,43 @@ export class LocalVariables implements Integration { } /** - * Adds local variables to the exception stack trace frames. + * Adds local variables event stack frames. */ private async _addLocalVariables(event: Event): Promise { - const hash = hashFrames(event?.exception?.values?.[0]?.stacktrace?.frames); + for (const exception of event?.exception?.values || []) { + await this._addLocalVariablesToException(exception); + } + + return event; + } + + /** + * Adds local variables to the exception stack frames. + */ + private async _addLocalVariablesToException(exception: Exception): Promise { + const hash = hashFrames(exception?.stacktrace?.frames); if (hash === undefined) { - return event; + return; } // Check if we have local variables for an exception that matches the hash const cachedFrames = await this._cachedFrames.get(hash); if (cachedFrames === undefined) { - return event; + return; } - const frameCount = event?.exception?.values?.[0]?.stacktrace?.frames?.length || 0; + await this._cachedFrames.delete(hash); + + const frameCount = exception.stacktrace?.frames?.length || 0; for (let i = 0; i < frameCount; i++) { // Sentry frames are in reverse order const frameIndex = frameCount - i - 1; // Drop out if we run out of frames to match up - if (!event?.exception?.values?.[0]?.stacktrace?.frames?.[frameIndex] || !cachedFrames[i]) { + if (!exception?.stacktrace?.frames?.[frameIndex] || !cachedFrames[i]) { break; } @@ -221,16 +233,14 @@ export class LocalVariables implements Integration { // We need to have vars to add cachedFrames[i].vars === undefined || // We're not interested in frames that are not in_app because the vars are not relevant - event.exception.values[0].stacktrace.frames[frameIndex].in_app === false || + exception.stacktrace.frames[frameIndex].in_app === false || // The function names need to match - !functionNamesMatch(event.exception.values[0].stacktrace.frames[frameIndex].function, cachedFrames[i].function) + !functionNamesMatch(exception.stacktrace.frames[frameIndex].function, cachedFrames[i].function) ) { continue; } - event.exception.values[0].stacktrace.frames[frameIndex].vars = cachedFrames[i].vars; + exception.stacktrace.frames[frameIndex].vars = cachedFrames[i].vars; } - - return event; } } From c842fb3a380d7b0990154490a0afbbcf74b6c60d Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 14 Dec 2022 22:45:27 +0000 Subject: [PATCH 13/19] Minor changes --- packages/node/src/integrations/localvariables.ts | 5 ++--- packages/node/src/sdk.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 2b6bf8cefd76..0e6f9d58d310 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -1,5 +1,4 @@ -import { getCurrentHub } from '@sentry/core'; -import { Event, EventProcessor, Exception, Integration, StackFrame, StackParser } from '@sentry/types'; +import { Event, EventProcessor, Exception, Hub, Integration, StackFrame, StackParser } from '@sentry/types'; import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; import { LRUMap } from 'lru_map'; @@ -81,7 +80,7 @@ export class LocalVariables implements Integration { /** * @inheritDoc */ - public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void { + public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { const options = getCurrentHub().getClient()?.getOptions(); if (options?._experiments?.includeStackLocals) { diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index 1dc0c968a8f5..a9279dd9a520 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -46,12 +46,12 @@ export const defaultIntegrations = [ new OnUnhandledRejection(), // Event Info new ContextLines(), + new LocalVariables(), new Context(), new Modules(), new RequestData(), // Misc new LinkedErrors(), - new LocalVariables(), ]; /** From 93cb95e24a95a6c9e713251946b038938e4f5670 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 15 Dec 2022 15:23:06 +0000 Subject: [PATCH 14/19] Add unit tests --- .../node/src/integrations/localvariables.ts | 149 ++++++---- .../test/integrations/localvariables.test.ts | 269 ++++++++++++++++++ 2 files changed, 358 insertions(+), 60 deletions(-) create mode 100644 packages/node/test/integrations/localvariables.test.ts diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 0e6f9d58d310..e74b6e44f745 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -1,7 +1,23 @@ -import { Event, EventProcessor, Exception, Hub, Integration, StackFrame, StackParser } from '@sentry/types'; +import { + ClientOptions, + Event, + EventProcessor, + Exception, + Hub, + Integration, + StackFrame, + StackParser, +} from '@sentry/types'; import { Debugger, InspectorNotification, Runtime, Session } from 'inspector'; import { LRUMap } from 'lru_map'; +export interface DebugSession { + /** Configures and connects to the debug session */ + configureAndConnect(onPause: (message: InspectorNotification) => void): void; + /** Gets local variables for an objectId */ + getLocalVariables(objectId: string): Promise>; +} + /** * Promise API is available as `Experimental` and in Node 19 only. * @@ -11,8 +27,38 @@ import { LRUMap } from 'lru_map'; * https://nodejs.org/docs/latest-v19.x/api/inspector.html#promises-api * https://nodejs.org/docs/latest-v14.x/api/inspector.html */ -class AsyncSession extends Session { - public getProperties(objectId: string): Promise { +class AsyncSession extends Session implements DebugSession { + /** @inheritdoc */ + public configureAndConnect(onPause: (message: InspectorNotification) => void): void { + this.connect(); + this.on('Debugger.paused', onPause); + this.post('Debugger.enable'); + // We only want to pause on uncaught exceptions + this.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); + } + + /** @inheritdoc */ + public async getLocalVariables(objectId: string): Promise> { + const props = await this._getProperties(objectId); + const unrolled: Record = {}; + + for (const prop of props) { + if (prop?.value?.objectId && prop?.value.className === 'Array') { + unrolled[prop.name] = await this._unrollArray(prop.value.objectId); + } else if (prop?.value?.objectId && prop?.value?.className === 'Object') { + unrolled[prop.name] = await this._unrollObject(prop.value.objectId); + } else if (prop?.value?.value || prop?.value?.description) { + unrolled[prop.name] = prop.value.value || `<${prop.value.description}>`; + } + } + + return unrolled; + } + + /** + * Gets all the PropertyDescriptors of an object + */ + private _getProperties(objectId: string): Promise { return new Promise((resolve, reject) => { this.post( 'Runtime.getProperties', @@ -30,6 +76,30 @@ class AsyncSession extends Session { ); }); } + + /** + * Unrolls an array property + */ + private async _unrollArray(objectId: string): Promise { + const props = await this._getProperties(objectId); + return props + .filter(v => v.name !== 'length' && !isNaN(parseInt(v.name, 10))) + .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) + .map(v => v?.value?.value); + } + + /** + * Unrolls an object property + */ + private async _unrollObject(objectId: string): Promise> { + const props = await this._getProperties(objectId); + return props + .map<[string, unknown]>(v => [v.name, v?.value?.value]) + .reduce((obj, [key, val]) => { + obj[key] = val; + return obj; + }, {} as Record); + } } // Add types for the exception event data @@ -60,7 +130,7 @@ function hashFrames(frames: StackFrame[] | undefined): string | undefined { return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); } -interface FrameVariables { +export interface FrameVariables { function: string; vars?: Record; } @@ -73,24 +143,27 @@ export class LocalVariables implements Integration { public readonly name: string = LocalVariables.id; - private readonly _session: AsyncSession = new AsyncSession(); private readonly _cachedFrames: LRUMap> = new LRUMap(20); private _stackParser: StackParser | undefined; + public constructor(private readonly _session: DebugSession = new AsyncSession()) {} + /** * @inheritDoc */ public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { - const options = getCurrentHub().getClient()?.getOptions(); + this._setup(addGlobalEventProcessor, getCurrentHub().getClient()?.getOptions()); + } - if (options?._experiments?.includeStackLocals) { - this._stackParser = options.stackParser; + /** Setup in a way that's easier to call from tests */ + private _setup( + addGlobalEventProcessor: (callback: EventProcessor) => void, + clientOptions: ClientOptions | undefined, + ): void { + if (clientOptions?._experiments?.includeStackLocals) { + this._stackParser = clientOptions.stackParser; - this._session.connect(); - this._session.on('Debugger.paused', this._handlePaused.bind(this)); - this._session.post('Debugger.enable'); - // We only want to pause on uncaught exceptions - this._session.post('Debugger.setPauseOnExceptions', { state: 'uncaught' }); + this._session.configureAndConnect(this._handlePaused.bind(this)); addGlobalEventProcessor(async event => this._addLocalVariables(event)); } @@ -134,7 +207,7 @@ export class LocalVariables implements Integration { return { function: fn }; } - const vars = await this._unrollProps(await this._session.getProperties(localScope.object.objectId)); + const vars = await this._session.getLocalVariables(localScope.object.objectId); return { function: fn, vars }; }); @@ -144,49 +217,6 @@ export class LocalVariables implements Integration { this._cachedFrames.set(exceptionHash, Promise.all(framePromises)); } - /** - * Unrolls all the properties - */ - private async _unrollProps(props: Runtime.PropertyDescriptor[]): Promise> { - const unrolled: Record = {}; - - for (const prop of props) { - if (prop?.value?.objectId && prop?.value.className === 'Array') { - unrolled[prop.name] = await this._unrollArray(prop.value.objectId); - } else if (prop?.value?.objectId && prop?.value?.className === 'Object') { - unrolled[prop.name] = await this._unrollObject(prop.value.objectId); - } else if (prop?.value?.value || prop?.value?.description) { - unrolled[prop.name] = prop.value.value || `<${prop.value.description}>`; - } - } - - return unrolled; - } - - /** - * Unrolls an array property - */ - private async _unrollArray(objectId: string): Promise { - const props = await this._session.getProperties(objectId); - return props - .filter(v => v.name !== 'length' && !isNaN(parseInt(v.name, 10))) - .sort((a, b) => parseInt(a.name, 10) - parseInt(b.name, 10)) - .map(v => v?.value?.value); - } - - /** - * Unrolls an object property - */ - private async _unrollObject(objectId: string): Promise> { - const props = await this._session.getProperties(objectId); - return props - .map<[string, unknown]>(v => [v.name, v?.value?.value]) - .reduce((obj, [key, val]) => { - obj[key] = val; - return obj; - }, {} as Record); - } - /** * Adds local variables event stack frames. */ @@ -209,14 +239,13 @@ export class LocalVariables implements Integration { } // Check if we have local variables for an exception that matches the hash - const cachedFrames = await this._cachedFrames.get(hash); + // delete is identical to get but also removes the entry from the cache + const cachedFrames = await this._cachedFrames.delete(hash); if (cachedFrames === undefined) { return; } - await this._cachedFrames.delete(hash); - const frameCount = exception.stacktrace?.frames?.length || 0; for (let i = 0; i < frameCount; i++) { diff --git a/packages/node/test/integrations/localvariables.test.ts b/packages/node/test/integrations/localvariables.test.ts new file mode 100644 index 000000000000..a0504971e154 --- /dev/null +++ b/packages/node/test/integrations/localvariables.test.ts @@ -0,0 +1,269 @@ +import { LocalVariables, DebugSession, FrameVariables } from '../../src/integrations/localvariables'; +import { InspectorNotification, Debugger } from 'inspector'; +import { EventProcessor, ClientOptions } from '@sentry/types'; +import { getDefaultNodeClientOptions } from '../helper/node-client-options'; +import { LRUMap } from 'lru_map'; + +import { defaultStackParser } from '../../src'; + +interface ThrowOn { + configureAndConnect?: boolean; + getLocalVariables?: boolean; +} + +class MockDebugSession implements DebugSession { + constructor(private readonly _vars: Record>, private readonly _throwOn?: ThrowOn) {} + + private _onPause?: (message: InspectorNotification) => void; + + public configureAndConnect(onPause: (message: InspectorNotification) => void): void { + if (this._throwOn?.configureAndConnect) { + throw new Error('configureAndConnect should not be called'); + } + + this._onPause = onPause; + } + + public async getLocalVariables(objectId: string): Promise> { + if (this._throwOn?.getLocalVariables) { + throw new Error('getLocalVariables should not be called'); + } + + return this._vars[objectId]; + } + + public runPause(message: InspectorNotification) { + this._onPause?.(message); + } +} + +interface LocalVariablesPrivate { + _cachedFrames: LRUMap>; + _setup(addGlobalEventProcessor: (callback: EventProcessor) => void, clientOptions: ClientOptions): void; +} + +const exceptionEvent = { + method: 'Debugger.paused', + params: { + reason: 'exception', + data: { + description: + 'Error: Some error\n' + + ' at two (/dist/javascript/src/main.js:23:9)\n' + + ' at one (/dist/javascript/src/main.js:19:3)\n' + + ' at Timeout._onTimeout (/dist/javascript/src/main.js:40:5)\n' + + ' at listOnTimeout (node:internal/timers:559:17)\n' + + ' at process.processTimers (node:internal/timers:502:7)', + }, + callFrames: [ + { + callFrameId: '-6224981551105448869.1.0', + functionName: 'two', + location: { scriptId: '134', lineNumber: 22 }, + url: '', + scopeChain: [ + { + type: 'local', + object: { + type: 'object', + className: 'Object', + objectId: '-6224981551105448869.1.2', + }, + name: 'two', + }, + ], + this: { + type: 'object', + className: 'global', + }, + }, + { + callFrameId: '-6224981551105448869.1.1', + functionName: 'one', + location: { scriptId: '134', lineNumber: 18 }, + url: '', + scopeChain: [ + { + type: 'local', + object: { + type: 'object', + className: 'Object', + objectId: '-6224981551105448869.1.6', + }, + name: 'one', + }, + ], + this: { + type: 'object', + className: 'global', + }, + }, + ], + }, +}; + +describe('LocalVariables', () => { + it('Adds local variables to stack frames', async () => { + expect.assertions(7); + + const session = new MockDebugSession({ + '-6224981551105448869.1.2': { name: 'tim' }, + '-6224981551105448869.1.6': { arr: [1, 2, 3] }, + }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: true }, + }); + + var eventProcessor: EventProcessor | undefined; + + (localVariables as unknown as LocalVariablesPrivate)._setup(callback => { + eventProcessor = callback; + }, options); + + expect(eventProcessor).toBeDefined(); + + session.runPause(exceptionEvent); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1); + + var frames: Promise | undefined; + + (localVariables as unknown as LocalVariablesPrivate)._cachedFrames.forEach(promise => { + frames = promise; + }); + + expect(frames).toBeDefined(); + + const vars = await (frames as Promise); + + expect(vars).toEqual([ + { function: 'two', vars: { name: 'tim' } }, + { function: 'one', vars: { arr: [1, 2, 3] } }, + ]); + + const event = await eventProcessor?.( + { + event_id: '9cbf882ade9a415986632ac4e16918eb', + platform: 'node', + timestamp: 1671113680.306, + level: 'fatal', + exception: { + values: [ + { + type: 'Error', + value: 'Some error', + stacktrace: { + frames: [ + { + function: 'process.processTimers', + lineno: 502, + colno: 7, + in_app: false, + }, + { + function: 'listOnTimeout', + lineno: 559, + colno: 17, + in_app: false, + }, + { + function: 'Timeout._onTimeout', + lineno: 40, + colno: 5, + in_app: true, + }, + { + function: 'one', + lineno: 19, + colno: 3, + in_app: true, + }, + { + function: 'two', + lineno: 23, + colno: 9, + in_app: true, + }, + ], + }, + mechanism: { type: 'generic', handled: true }, + }, + ], + }, + }, + {}, + ); + + expect(event?.exception?.values?.[0].stacktrace?.frames?.[3]?.vars).toEqual({ arr: [1, 2, 3] }); + expect(event?.exception?.values?.[0].stacktrace?.frames?.[4]?.vars).toEqual({ name: 'tim' }); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(0); + }); + + it('Should not lookup variables for non-exception reasons', async () => { + expect.assertions(1); + + const session = new MockDebugSession({}, { getLocalVariables: true }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: true }, + }); + + (localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options); + + const nonExceptionEvent = { + method: exceptionEvent.method, + params: { ...exceptionEvent.params, reason: 'non-exception-reason' }, + }; + + session.runPause(nonExceptionEvent); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(0); + }); + + it('Should not initialize when disabled', async () => { + expect.assertions(1); + + const session = new MockDebugSession({}, { configureAndConnect: true }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: false }, + }); + + var eventProcessor: EventProcessor | undefined; + + (localVariables as unknown as LocalVariablesPrivate)._setup(callback => { + eventProcessor = callback; + }, options); + + expect(eventProcessor).toBeUndefined(); + }); + + it.only('Should cache identical uncaught exception events', async () => { + expect.assertions(1); + + const session = new MockDebugSession({ + '-6224981551105448869.1.2': { name: 'tim' }, + '-6224981551105448869.1.6': { arr: [1, 2, 3] }, + }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: true }, + }); + + (localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options); + + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1); + }); +}); From e3d11f3b8437d0989c45b023d5c331d341287181 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 15 Dec 2022 15:32:41 +0000 Subject: [PATCH 15/19] remove lint disable --- packages/node/src/sdk.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index a9279dd9a520..d70d8ec73180 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -109,7 +109,6 @@ export const defaultIntegrations = [ * * @see {@link NodeOptions} for documentation on configuration options. */ -// eslint-disable-next-line complexity export function init(options: NodeOptions = {}): void { const carrier = getMainCarrier(); const autoloadedIntegrations = carrier.__SENTRY__?.integrations || []; From e2b1f71e700afa9c9f1690959ec5c5a85e03401d Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 15 Dec 2022 15:38:00 +0000 Subject: [PATCH 16/19] Remove nullable stackParser property --- .../node/src/integrations/localvariables.ts | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index e74b6e44f745..90ad5109ed30 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -130,6 +130,18 @@ function hashFrames(frames: StackFrame[] | undefined): string | undefined { return frames.slice(-10).reduce((acc, frame) => `${acc},${frame.function},${frame.lineno},${frame.colno}`, ''); } +/** + * We use the stack parser to create a unique hash from the exception stack trace + * This is used to lookup vars when the exception passes through the event processor + */ +function hashFromStack(stackParser: StackParser, stack: string | undefined): string | undefined { + if (stack === undefined) { + return undefined; + } + + return hashFrames(stackParser(stack, 1)); +} + export interface FrameVariables { function: string; vars?: Record; @@ -144,7 +156,6 @@ export class LocalVariables implements Integration { public readonly name: string = LocalVariables.id; private readonly _cachedFrames: LRUMap> = new LRUMap(20); - private _stackParser: StackParser | undefined; public constructor(private readonly _session: DebugSession = new AsyncSession()) {} @@ -161,38 +172,27 @@ export class LocalVariables implements Integration { clientOptions: ClientOptions | undefined, ): void { if (clientOptions?._experiments?.includeStackLocals) { - this._stackParser = clientOptions.stackParser; - - this._session.configureAndConnect(this._handlePaused.bind(this)); + this._session.configureAndConnect(ev => + this._handlePaused(clientOptions.stackParser, ev as InspectorNotification), + ); addGlobalEventProcessor(async event => this._addLocalVariables(event)); } } - /** - * We use the stack parser to create a unique hash from the exception stack trace - * This is used to lookup vars when the exception passes through the event processor - */ - private _hashFromStack(stack: string | undefined): string | undefined { - if (this._stackParser === undefined || stack === undefined) { - return undefined; - } - - return hashFrames(this._stackParser(stack, 1)); - } - /** * Handle the pause event */ - private async _handlePaused({ - params: { reason, data, callFrames }, - }: InspectorNotification): Promise { + private async _handlePaused( + stackParser: StackParser, + { params: { reason, data, callFrames } }: InspectorNotification, + ): Promise { if (reason !== 'exception' && reason !== 'promiseRejection') { return; } // data.description contains the original error.stack - const exceptionHash = this._hashFromStack(data?.description); + const exceptionHash = hashFromStack(stackParser, data?.description); if (exceptionHash == undefined) { return; From 0b7fd394bbc92d808e6a5bc92c901a48025de94d Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 15 Dec 2022 16:00:39 +0000 Subject: [PATCH 17/19] I miss test lint warnings --- .../test/integrations/localvariables.test.ts | 538 +++++++++--------- 1 file changed, 269 insertions(+), 269 deletions(-) diff --git a/packages/node/test/integrations/localvariables.test.ts b/packages/node/test/integrations/localvariables.test.ts index a0504971e154..9b60739fb852 100644 --- a/packages/node/test/integrations/localvariables.test.ts +++ b/packages/node/test/integrations/localvariables.test.ts @@ -1,269 +1,269 @@ -import { LocalVariables, DebugSession, FrameVariables } from '../../src/integrations/localvariables'; -import { InspectorNotification, Debugger } from 'inspector'; -import { EventProcessor, ClientOptions } from '@sentry/types'; -import { getDefaultNodeClientOptions } from '../helper/node-client-options'; -import { LRUMap } from 'lru_map'; - -import { defaultStackParser } from '../../src'; - -interface ThrowOn { - configureAndConnect?: boolean; - getLocalVariables?: boolean; -} - -class MockDebugSession implements DebugSession { - constructor(private readonly _vars: Record>, private readonly _throwOn?: ThrowOn) {} - - private _onPause?: (message: InspectorNotification) => void; - - public configureAndConnect(onPause: (message: InspectorNotification) => void): void { - if (this._throwOn?.configureAndConnect) { - throw new Error('configureAndConnect should not be called'); - } - - this._onPause = onPause; - } - - public async getLocalVariables(objectId: string): Promise> { - if (this._throwOn?.getLocalVariables) { - throw new Error('getLocalVariables should not be called'); - } - - return this._vars[objectId]; - } - - public runPause(message: InspectorNotification) { - this._onPause?.(message); - } -} - -interface LocalVariablesPrivate { - _cachedFrames: LRUMap>; - _setup(addGlobalEventProcessor: (callback: EventProcessor) => void, clientOptions: ClientOptions): void; -} - -const exceptionEvent = { - method: 'Debugger.paused', - params: { - reason: 'exception', - data: { - description: - 'Error: Some error\n' + - ' at two (/dist/javascript/src/main.js:23:9)\n' + - ' at one (/dist/javascript/src/main.js:19:3)\n' + - ' at Timeout._onTimeout (/dist/javascript/src/main.js:40:5)\n' + - ' at listOnTimeout (node:internal/timers:559:17)\n' + - ' at process.processTimers (node:internal/timers:502:7)', - }, - callFrames: [ - { - callFrameId: '-6224981551105448869.1.0', - functionName: 'two', - location: { scriptId: '134', lineNumber: 22 }, - url: '', - scopeChain: [ - { - type: 'local', - object: { - type: 'object', - className: 'Object', - objectId: '-6224981551105448869.1.2', - }, - name: 'two', - }, - ], - this: { - type: 'object', - className: 'global', - }, - }, - { - callFrameId: '-6224981551105448869.1.1', - functionName: 'one', - location: { scriptId: '134', lineNumber: 18 }, - url: '', - scopeChain: [ - { - type: 'local', - object: { - type: 'object', - className: 'Object', - objectId: '-6224981551105448869.1.6', - }, - name: 'one', - }, - ], - this: { - type: 'object', - className: 'global', - }, - }, - ], - }, -}; - -describe('LocalVariables', () => { - it('Adds local variables to stack frames', async () => { - expect.assertions(7); - - const session = new MockDebugSession({ - '-6224981551105448869.1.2': { name: 'tim' }, - '-6224981551105448869.1.6': { arr: [1, 2, 3] }, - }); - const localVariables = new LocalVariables(session); - const options = getDefaultNodeClientOptions({ - stackParser: defaultStackParser, - _experiments: { includeStackLocals: true }, - }); - - var eventProcessor: EventProcessor | undefined; - - (localVariables as unknown as LocalVariablesPrivate)._setup(callback => { - eventProcessor = callback; - }, options); - - expect(eventProcessor).toBeDefined(); - - session.runPause(exceptionEvent); - - expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1); - - var frames: Promise | undefined; - - (localVariables as unknown as LocalVariablesPrivate)._cachedFrames.forEach(promise => { - frames = promise; - }); - - expect(frames).toBeDefined(); - - const vars = await (frames as Promise); - - expect(vars).toEqual([ - { function: 'two', vars: { name: 'tim' } }, - { function: 'one', vars: { arr: [1, 2, 3] } }, - ]); - - const event = await eventProcessor?.( - { - event_id: '9cbf882ade9a415986632ac4e16918eb', - platform: 'node', - timestamp: 1671113680.306, - level: 'fatal', - exception: { - values: [ - { - type: 'Error', - value: 'Some error', - stacktrace: { - frames: [ - { - function: 'process.processTimers', - lineno: 502, - colno: 7, - in_app: false, - }, - { - function: 'listOnTimeout', - lineno: 559, - colno: 17, - in_app: false, - }, - { - function: 'Timeout._onTimeout', - lineno: 40, - colno: 5, - in_app: true, - }, - { - function: 'one', - lineno: 19, - colno: 3, - in_app: true, - }, - { - function: 'two', - lineno: 23, - colno: 9, - in_app: true, - }, - ], - }, - mechanism: { type: 'generic', handled: true }, - }, - ], - }, - }, - {}, - ); - - expect(event?.exception?.values?.[0].stacktrace?.frames?.[3]?.vars).toEqual({ arr: [1, 2, 3] }); - expect(event?.exception?.values?.[0].stacktrace?.frames?.[4]?.vars).toEqual({ name: 'tim' }); - - expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(0); - }); - - it('Should not lookup variables for non-exception reasons', async () => { - expect.assertions(1); - - const session = new MockDebugSession({}, { getLocalVariables: true }); - const localVariables = new LocalVariables(session); - const options = getDefaultNodeClientOptions({ - stackParser: defaultStackParser, - _experiments: { includeStackLocals: true }, - }); - - (localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options); - - const nonExceptionEvent = { - method: exceptionEvent.method, - params: { ...exceptionEvent.params, reason: 'non-exception-reason' }, - }; - - session.runPause(nonExceptionEvent); - - expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(0); - }); - - it('Should not initialize when disabled', async () => { - expect.assertions(1); - - const session = new MockDebugSession({}, { configureAndConnect: true }); - const localVariables = new LocalVariables(session); - const options = getDefaultNodeClientOptions({ - stackParser: defaultStackParser, - _experiments: { includeStackLocals: false }, - }); - - var eventProcessor: EventProcessor | undefined; - - (localVariables as unknown as LocalVariablesPrivate)._setup(callback => { - eventProcessor = callback; - }, options); - - expect(eventProcessor).toBeUndefined(); - }); - - it.only('Should cache identical uncaught exception events', async () => { - expect.assertions(1); - - const session = new MockDebugSession({ - '-6224981551105448869.1.2': { name: 'tim' }, - '-6224981551105448869.1.6': { arr: [1, 2, 3] }, - }); - const localVariables = new LocalVariables(session); - const options = getDefaultNodeClientOptions({ - stackParser: defaultStackParser, - _experiments: { includeStackLocals: true }, - }); - - (localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options); - - session.runPause(exceptionEvent); - session.runPause(exceptionEvent); - session.runPause(exceptionEvent); - session.runPause(exceptionEvent); - session.runPause(exceptionEvent); - - expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1); - }); -}); +import { ClientOptions, EventProcessor } from '@sentry/types'; +import { Debugger, InspectorNotification } from 'inspector'; +import { LRUMap } from 'lru_map'; + +import { defaultStackParser } from '../../src'; +import { DebugSession, FrameVariables, LocalVariables } from '../../src/integrations/localvariables'; +import { getDefaultNodeClientOptions } from '../../test/helper/node-client-options'; + +interface ThrowOn { + configureAndConnect?: boolean; + getLocalVariables?: boolean; +} + +class MockDebugSession implements DebugSession { + private _onPause?: (message: InspectorNotification) => void; + + constructor(private readonly _vars: Record>, private readonly _throwOn?: ThrowOn) {} + + public configureAndConnect(onPause: (message: InspectorNotification) => void): void { + if (this._throwOn?.configureAndConnect) { + throw new Error('configureAndConnect should not be called'); + } + + this._onPause = onPause; + } + + public async getLocalVariables(objectId: string): Promise> { + if (this._throwOn?.getLocalVariables) { + throw new Error('getLocalVariables should not be called'); + } + + return this._vars[objectId]; + } + + public runPause(message: InspectorNotification) { + this._onPause?.(message); + } +} + +interface LocalVariablesPrivate { + _cachedFrames: LRUMap>; + _setup(addGlobalEventProcessor: (callback: EventProcessor) => void, clientOptions: ClientOptions): void; +} + +const exceptionEvent = { + method: 'Debugger.paused', + params: { + reason: 'exception', + data: { + description: + 'Error: Some error\n' + + ' at two (/dist/javascript/src/main.js:23:9)\n' + + ' at one (/dist/javascript/src/main.js:19:3)\n' + + ' at Timeout._onTimeout (/dist/javascript/src/main.js:40:5)\n' + + ' at listOnTimeout (node:internal/timers:559:17)\n' + + ' at process.processTimers (node:internal/timers:502:7)', + }, + callFrames: [ + { + callFrameId: '-6224981551105448869.1.0', + functionName: 'two', + location: { scriptId: '134', lineNumber: 22 }, + url: '', + scopeChain: [ + { + type: 'local', + object: { + type: 'object', + className: 'Object', + objectId: '-6224981551105448869.1.2', + }, + name: 'two', + }, + ], + this: { + type: 'object', + className: 'global', + }, + }, + { + callFrameId: '-6224981551105448869.1.1', + functionName: 'one', + location: { scriptId: '134', lineNumber: 18 }, + url: '', + scopeChain: [ + { + type: 'local', + object: { + type: 'object', + className: 'Object', + objectId: '-6224981551105448869.1.6', + }, + name: 'one', + }, + ], + this: { + type: 'object', + className: 'global', + }, + }, + ], + }, +}; + +describe('LocalVariables', () => { + it('Adds local variables to stack frames', async () => { + expect.assertions(7); + + const session = new MockDebugSession({ + '-6224981551105448869.1.2': { name: 'tim' }, + '-6224981551105448869.1.6': { arr: [1, 2, 3] }, + }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: true }, + }); + + let eventProcessor: EventProcessor | undefined; + + (localVariables as unknown as LocalVariablesPrivate)._setup(callback => { + eventProcessor = callback; + }, options); + + expect(eventProcessor).toBeDefined(); + + session.runPause(exceptionEvent); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1); + + let frames: Promise | undefined; + + (localVariables as unknown as LocalVariablesPrivate)._cachedFrames.forEach(promise => { + frames = promise; + }); + + expect(frames).toBeDefined(); + + const vars = await (frames as Promise); + + expect(vars).toEqual([ + { function: 'two', vars: { name: 'tim' } }, + { function: 'one', vars: { arr: [1, 2, 3] } }, + ]); + + const event = await eventProcessor?.( + { + event_id: '9cbf882ade9a415986632ac4e16918eb', + platform: 'node', + timestamp: 1671113680.306, + level: 'fatal', + exception: { + values: [ + { + type: 'Error', + value: 'Some error', + stacktrace: { + frames: [ + { + function: 'process.processTimers', + lineno: 502, + colno: 7, + in_app: false, + }, + { + function: 'listOnTimeout', + lineno: 559, + colno: 17, + in_app: false, + }, + { + function: 'Timeout._onTimeout', + lineno: 40, + colno: 5, + in_app: true, + }, + { + function: 'one', + lineno: 19, + colno: 3, + in_app: true, + }, + { + function: 'two', + lineno: 23, + colno: 9, + in_app: true, + }, + ], + }, + mechanism: { type: 'generic', handled: true }, + }, + ], + }, + }, + {}, + ); + + expect(event?.exception?.values?.[0].stacktrace?.frames?.[3]?.vars).toEqual({ arr: [1, 2, 3] }); + expect(event?.exception?.values?.[0].stacktrace?.frames?.[4]?.vars).toEqual({ name: 'tim' }); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(0); + }); + + it('Should not lookup variables for non-exception reasons', async () => { + expect.assertions(1); + + const session = new MockDebugSession({}, { getLocalVariables: true }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: true }, + }); + + (localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options); + + const nonExceptionEvent = { + method: exceptionEvent.method, + params: { ...exceptionEvent.params, reason: 'non-exception-reason' }, + }; + + session.runPause(nonExceptionEvent); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(0); + }); + + it('Should not initialize when disabled', async () => { + expect.assertions(1); + + const session = new MockDebugSession({}, { configureAndConnect: true }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: false }, + }); + + let eventProcessor: EventProcessor | undefined; + + (localVariables as unknown as LocalVariablesPrivate)._setup(callback => { + eventProcessor = callback; + }, options); + + expect(eventProcessor).toBeUndefined(); + }); + + it.only('Should cache identical uncaught exception events', async () => { + expect.assertions(1); + + const session = new MockDebugSession({ + '-6224981551105448869.1.2': { name: 'tim' }, + '-6224981551105448869.1.6': { arr: [1, 2, 3] }, + }); + const localVariables = new LocalVariables(session); + const options = getDefaultNodeClientOptions({ + stackParser: defaultStackParser, + _experiments: { includeStackLocals: true }, + }); + + (localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options); + + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + session.runPause(exceptionEvent); + + expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1); + }); +}); From 2c144d0810bece86044ec78af028dd39d30ca7a6 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 9 Jan 2023 11:20:54 +0000 Subject: [PATCH 18/19] Add empty options object as first constructor param --- packages/node/src/integrations/localvariables.ts | 7 ++++++- packages/node/test/integrations/localvariables.test.ts | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 90ad5109ed30..83375e93100b 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -147,6 +147,11 @@ export interface FrameVariables { vars?: Record; } +// eslint-disable-next-line @typescript-eslint/no-empty-interface +interface Options { + // No options yet but this allows them to be added later without breaking changes +} + /** * Adds local variables to exception frames */ @@ -157,7 +162,7 @@ export class LocalVariables implements Integration { private readonly _cachedFrames: LRUMap> = new LRUMap(20); - public constructor(private readonly _session: DebugSession = new AsyncSession()) {} + public constructor(_options: Options = {}, private readonly _session: DebugSession = new AsyncSession()) {} /** * @inheritDoc diff --git a/packages/node/test/integrations/localvariables.test.ts b/packages/node/test/integrations/localvariables.test.ts index 9b60739fb852..a9756e11d623 100644 --- a/packages/node/test/integrations/localvariables.test.ts +++ b/packages/node/test/integrations/localvariables.test.ts @@ -110,7 +110,7 @@ describe('LocalVariables', () => { '-6224981551105448869.1.2': { name: 'tim' }, '-6224981551105448869.1.6': { arr: [1, 2, 3] }, }); - const localVariables = new LocalVariables(session); + const localVariables = new LocalVariables({}, session); const options = getDefaultNodeClientOptions({ stackParser: defaultStackParser, _experiments: { includeStackLocals: true }, @@ -206,7 +206,7 @@ describe('LocalVariables', () => { expect.assertions(1); const session = new MockDebugSession({}, { getLocalVariables: true }); - const localVariables = new LocalVariables(session); + const localVariables = new LocalVariables({}, session); const options = getDefaultNodeClientOptions({ stackParser: defaultStackParser, _experiments: { includeStackLocals: true }, @@ -228,7 +228,7 @@ describe('LocalVariables', () => { expect.assertions(1); const session = new MockDebugSession({}, { configureAndConnect: true }); - const localVariables = new LocalVariables(session); + const localVariables = new LocalVariables({}, session); const options = getDefaultNodeClientOptions({ stackParser: defaultStackParser, _experiments: { includeStackLocals: false }, @@ -250,7 +250,7 @@ describe('LocalVariables', () => { '-6224981551105448869.1.2': { name: 'tim' }, '-6224981551105448869.1.6': { arr: [1, 2, 3] }, }); - const localVariables = new LocalVariables(session); + const localVariables = new LocalVariables({}, session); const options = getDefaultNodeClientOptions({ stackParser: defaultStackParser, _experiments: { includeStackLocals: true }, From bd351cc3320dde0691ab205f5836404e5c109346 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 9 Jan 2023 11:24:46 +0000 Subject: [PATCH 19/19] jsdocs --- packages/node/src/integrations/localvariables.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/node/src/integrations/localvariables.ts b/packages/node/src/integrations/localvariables.ts index 83375e93100b..fc82e1a611f0 100644 --- a/packages/node/src/integrations/localvariables.ts +++ b/packages/node/src/integrations/localvariables.ts @@ -147,10 +147,9 @@ export interface FrameVariables { vars?: Record; } +/** There are no options yet. This allows them to be added later without breaking changes */ // eslint-disable-next-line @typescript-eslint/no-empty-interface -interface Options { - // No options yet but this allows them to be added later without breaking changes -} +interface Options {} /** * Adds local variables to exception frames