Usage in Deno
import { Session } from "node:inspector";
Session.prototype.post(method: string,callback?: (err: Error | null,params?: object,) => void,): 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.
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.
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.
void
Session.prototype.post(method: string,params?: object,callback?: (err: Error | null,params?: object,) => void,): void
Session.prototype.post(method: "Schema.getDomains",callback?: (err: Error | null,params: Schema.GetDomainsReturnType,) => void,): void
Returns supported domains.
callback: (err: Error | null,params: Schema.GetDomainsReturnType,) => void
void
Session.prototype.post(method: "Runtime.evaluate",params?: Runtime.EvaluateParameterType,callback?: (err: Error | null,params: Runtime.EvaluateReturnType,) => void,): void
Evaluates expression on global object.
params: Runtime.EvaluateParameterType
callback: (err: Error | null,params: Runtime.EvaluateReturnType,) => void
void
Session.prototype.post(method: "Runtime.evaluate",callback?: (err: Error | null,params: Runtime.EvaluateReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.EvaluateReturnType,) => void
void
Session.prototype.post(method: "Runtime.awaitPromise",params?: Runtime.AwaitPromiseParameterType,callback?: (err: Error | null,params: Runtime.AwaitPromiseReturnType,) => void,): void
Add handler to promise with given promise object id.
params: Runtime.AwaitPromiseParameterType
callback: (err: Error | null,params: Runtime.AwaitPromiseReturnType,) => void
void
Session.prototype.post(method: "Runtime.awaitPromise",callback?: (err: Error | null,params: Runtime.AwaitPromiseReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.AwaitPromiseReturnType,) => void
void
Session.prototype.post(method: "Runtime.callFunctionOn",params?: Runtime.CallFunctionOnParameterType,callback?: (err: Error | null,params: Runtime.CallFunctionOnReturnType,) => void,): void
Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
params: Runtime.CallFunctionOnParameterType
callback: (err: Error | null,params: Runtime.CallFunctionOnReturnType,) => void
void
Session.prototype.post(method: "Runtime.callFunctionOn",callback?: (err: Error | null,params: Runtime.CallFunctionOnReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.CallFunctionOnReturnType,) => void
void
Session.prototype.post(method: "Runtime.getProperties",params?: Runtime.GetPropertiesParameterType,callback?: (err: Error | null,params: Runtime.GetPropertiesReturnType,) => void,): void
Returns properties of a given object. Object group of the result is inherited from the target object.
params: Runtime.GetPropertiesParameterType
callback: (err: Error | null,params: Runtime.GetPropertiesReturnType,) => void
void
Session.prototype.post(method: "Runtime.getProperties",callback?: (err: Error | null,params: Runtime.GetPropertiesReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.GetPropertiesReturnType,) => void
void
Session.prototype.post(method: "Runtime.releaseObject",params?: Runtime.ReleaseObjectParameterType,callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Runtime.releaseObject",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Runtime.releaseObjectGroup",params?: Runtime.ReleaseObjectGroupParameterType,callback?: (err: Error | null) => void,): void
Releases all remote objects that belong to a given group.
params: Runtime.ReleaseObjectGroupParameterType
void
Session.prototype.post(method: "Runtime.releaseObjectGroup",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Runtime.runIfWaitingForDebugger",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Runtime.enable",callback?: (err: Error | null) => void,): void
Enables reporting of execution contexts creation by means of <code>executionContextCreated</code> event. When the reporting gets enabled the event will be sent immediately for each existing execution context.
void
Session.prototype.post(method: "Runtime.discardConsoleEntries",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Runtime.setCustomObjectFormatterEnabled",callback?: (err: Error | null) => void,): void
params: Runtime.SetCustomObjectFormatterEnabledParameterType
void
Session.prototype.post(method: "Runtime.setCustomObjectFormatterEnabled",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Runtime.compileScript",params?: Runtime.CompileScriptParameterType,callback?: (err: Error | null,params: Runtime.CompileScriptReturnType,) => void,): void
Compiles expression.
params: Runtime.CompileScriptParameterType
callback: (err: Error | null,params: Runtime.CompileScriptReturnType,) => void
void
Session.prototype.post(method: "Runtime.compileScript",callback?: (err: Error | null,params: Runtime.CompileScriptReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.CompileScriptReturnType,) => void
void
Session.prototype.post(method: "Runtime.runScript",params?: Runtime.RunScriptParameterType,callback?: (err: Error | null,params: Runtime.RunScriptReturnType,) => void,): void
Runs script with given id in a given context.
params: Runtime.RunScriptParameterType
callback: (err: Error | null,params: Runtime.RunScriptReturnType,) => void
void
Session.prototype.post(method: "Runtime.runScript",callback?: (err: Error | null,params: Runtime.RunScriptReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.RunScriptReturnType,) => void
void
Session.prototype.post(method: "Runtime.queryObjects",params?: Runtime.QueryObjectsParameterType,callback?: (err: Error | null,params: Runtime.QueryObjectsReturnType,) => void,): void
params: Runtime.QueryObjectsParameterType
callback: (err: Error | null,params: Runtime.QueryObjectsReturnType,) => void
void
Session.prototype.post(method: "Runtime.queryObjects",callback?: (err: Error | null,params: Runtime.QueryObjectsReturnType,) => void,): void
callback: (err: Error | null,params: Runtime.QueryObjectsReturnType,) => void
void
Session.prototype.post(method: "Runtime.globalLexicalScopeNames",callback?: (err: Error | null,) => void,): void
Returns all let, const and class variables from global scope.
params: Runtime.GlobalLexicalScopeNamesParameterType
void
Session.prototype.post(method: "Runtime.globalLexicalScopeNames",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "Debugger.enable",callback?: (err: Error | null,params: Debugger.EnableReturnType,) => 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.
callback: (err: Error | null,params: Debugger.EnableReturnType,) => void
void
Session.prototype.post(method: "Debugger.setBreakpointsActive",callback?: (err: Error | null) => void,): void
Activates / deactivates all breakpoints on the page.
params: Debugger.SetBreakpointsActiveParameterType
void
Session.prototype.post(method: "Debugger.setBreakpointsActive",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.setSkipAllPauses",params?: Debugger.SetSkipAllPausesParameterType,callback?: (err: Error | null) => void,): void
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
params: Debugger.SetSkipAllPausesParameterType
void
Session.prototype.post(method: "Debugger.setSkipAllPauses",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.setBreakpointByUrl",params?: Debugger.SetBreakpointByUrlParameterType,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 <code>locations</code> property. Further matching script parsing will result in subsequent <code>breakpointResolved</code> events issued. This logical breakpoint will survive page reloads.
params: Debugger.SetBreakpointByUrlParameterType
void
Session.prototype.post(method: "Debugger.setBreakpointByUrl",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "Debugger.setBreakpoint",params?: Debugger.SetBreakpointParameterType,callback?: (err: Error | null,params: Debugger.SetBreakpointReturnType,) => void,): void
Sets JavaScript breakpoint at a given location.
params: Debugger.SetBreakpointParameterType
callback: (err: Error | null,params: Debugger.SetBreakpointReturnType,) => void
void
Session.prototype.post(method: "Debugger.setBreakpoint",callback?: (err: Error | null,params: Debugger.SetBreakpointReturnType,) => void,): void
callback: (err: Error | null,params: Debugger.SetBreakpointReturnType,) => void
void
Session.prototype.post(method: "Debugger.removeBreakpoint",params?: Debugger.RemoveBreakpointParameterType,callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.removeBreakpoint",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.getPossibleBreakpoints",callback?: (err: Error | null,) => void,): void
Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.
params: Debugger.GetPossibleBreakpointsParameterType
void
Session.prototype.post(method: "Debugger.getPossibleBreakpoints",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "Debugger.continueToLocation",params?: Debugger.ContinueToLocationParameterType,callback?: (err: Error | null) => void,): void
Continues execution until specific location is reached.
params: Debugger.ContinueToLocationParameterType
void
Session.prototype.post(method: "Debugger.continueToLocation",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.pauseOnAsyncCall",params?: Debugger.PauseOnAsyncCallParameterType,callback?: (err: Error | null) => void,): void
params: Debugger.PauseOnAsyncCallParameterType
void
Session.prototype.post(method: "Debugger.pauseOnAsyncCall",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.stepInto",params?: Debugger.StepIntoParameterType,callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.scheduleStepIntoAsync",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.
void
Session.prototype.post(method: "Debugger.getStackTrace",params?: Debugger.GetStackTraceParameterType,callback?: (err: Error | null,params: Debugger.GetStackTraceReturnType,) => void,): void
Returns stack trace with given <code>stackTraceId</code>.
params: Debugger.GetStackTraceParameterType
callback: (err: Error | null,params: Debugger.GetStackTraceReturnType,) => void
void
Session.prototype.post(method: "Debugger.getStackTrace",callback?: (err: Error | null,params: Debugger.GetStackTraceReturnType,) => void,): void
callback: (err: Error | null,params: Debugger.GetStackTraceReturnType,) => void
void
Session.prototype.post(method: "Debugger.searchInContent",params?: Debugger.SearchInContentParameterType,callback?: (err: Error | null,params: Debugger.SearchInContentReturnType,) => void,): void
Searches for given string in script content.
params: Debugger.SearchInContentParameterType
callback: (err: Error | null,params: Debugger.SearchInContentReturnType,) => void
void
Session.prototype.post(method: "Debugger.searchInContent",callback?: (err: Error | null,params: Debugger.SearchInContentReturnType,) => void,): void
callback: (err: Error | null,params: Debugger.SearchInContentReturnType,) => void
void
Session.prototype.post(method: "Debugger.setScriptSource",params?: Debugger.SetScriptSourceParameterType,callback?: (err: Error | null,params: Debugger.SetScriptSourceReturnType,) => void,): void
Edits JavaScript source live.
params: Debugger.SetScriptSourceParameterType
callback: (err: Error | null,params: Debugger.SetScriptSourceReturnType,) => void
void
Session.prototype.post(method: "Debugger.setScriptSource",callback?: (err: Error | null,params: Debugger.SetScriptSourceReturnType,) => void,): void
callback: (err: Error | null,params: Debugger.SetScriptSourceReturnType,) => void
void
Session.prototype.post(method: "Debugger.restartFrame",params?: Debugger.RestartFrameParameterType,callback?: (err: Error | null,params: Debugger.RestartFrameReturnType,) => void,): void
Restarts particular call frame from the beginning.
params: Debugger.RestartFrameParameterType
callback: (err: Error | null,params: Debugger.RestartFrameReturnType,) => void
void
Session.prototype.post(method: "Debugger.restartFrame",callback?: (err: Error | null,params: Debugger.RestartFrameReturnType,) => void,): void
callback: (err: Error | null,params: Debugger.RestartFrameReturnType,) => void
void
Session.prototype.post(method: "Debugger.getScriptSource",params?: Debugger.GetScriptSourceParameterType,callback?: (err: Error | null,params: Debugger.GetScriptSourceReturnType,) => void,): void
Returns source for the script with given id.
params: Debugger.GetScriptSourceParameterType
callback: (err: Error | null,params: Debugger.GetScriptSourceReturnType,) => void
void
Session.prototype.post(method: "Debugger.getScriptSource",callback?: (err: Error | null,params: Debugger.GetScriptSourceReturnType,) => void,): void
callback: (err: Error | null,params: Debugger.GetScriptSourceReturnType,) => void
void
Session.prototype.post(method: "Debugger.setPauseOnExceptions",callback?: (err: Error | null) => 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 <code>none</code>.
params: Debugger.SetPauseOnExceptionsParameterType
void
Session.prototype.post(method: "Debugger.setPauseOnExceptions",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.evaluateOnCallFrame",callback?: (err: Error | null,) => void,): void
Evaluates expression on a given call frame.
params: Debugger.EvaluateOnCallFrameParameterType
void
Session.prototype.post(method: "Debugger.evaluateOnCallFrame",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "Debugger.setVariableValue",params?: Debugger.SetVariableValueParameterType,callback?: (err: Error | null) => void,): void
Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.
params: Debugger.SetVariableValueParameterType
void
Session.prototype.post(method: "Debugger.setVariableValue",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.setReturnValue",params?: Debugger.SetReturnValueParameterType,callback?: (err: Error | null) => void,): void
Changes return value in top frame. Available only at return break position.
params: Debugger.SetReturnValueParameterType
void
Session.prototype.post(method: "Debugger.setReturnValue",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.setAsyncCallStackDepth",callback?: (err: Error | null) => void,): void
Enables or disables async call stacks tracking.
params: Debugger.SetAsyncCallStackDepthParameterType
void
Session.prototype.post(method: "Debugger.setAsyncCallStackDepth",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.setBlackboxPatterns",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.
params: Debugger.SetBlackboxPatternsParameterType
void
Session.prototype.post(method: "Debugger.setBlackboxPatterns",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Debugger.setBlackboxedRanges",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.
params: Debugger.SetBlackboxedRangesParameterType
void
Session.prototype.post(method: "Debugger.setBlackboxedRanges",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Console.clearMessages",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Profiler.setSamplingInterval",callback?: (err: Error | null) => void,): void
Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
params: Profiler.SetSamplingIntervalParameterType
void
Session.prototype.post(method: "Profiler.setSamplingInterval",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Profiler.stop",callback?: (err: Error | null,params: Profiler.StopReturnType,) => void,): void
callback: (err: Error | null,params: Profiler.StopReturnType,) => void
void
Session.prototype.post(method: "Profiler.startPreciseCoverage",callback?: (err: Error | null) => 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.
params: Profiler.StartPreciseCoverageParameterType
void
Session.prototype.post(method: "Profiler.startPreciseCoverage",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Profiler.stopPreciseCoverage",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "Profiler.takePreciseCoverage",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "Profiler.getBestEffortCoverage",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "HeapProfiler.disable",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.startTrackingHeapObjects",callback?: (err: Error | null) => void,): void
params: HeapProfiler.StartTrackingHeapObjectsParameterType
void
Session.prototype.post(method: "HeapProfiler.startTrackingHeapObjects",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.stopTrackingHeapObjects",callback?: (err: Error | null) => void,): void
params: HeapProfiler.StopTrackingHeapObjectsParameterType
void
Session.prototype.post(method: "HeapProfiler.stopTrackingHeapObjects",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.takeHeapSnapshot",callback?: (err: Error | null) => void,): void
params: HeapProfiler.TakeHeapSnapshotParameterType
void
Session.prototype.post(method: "HeapProfiler.takeHeapSnapshot",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.collectGarbage",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.getObjectByHeapObjectId",callback?: (err: Error | null,) => void,): void
params: HeapProfiler.GetObjectByHeapObjectIdParameterType
void
Session.prototype.post(method: "HeapProfiler.getObjectByHeapObjectId",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "HeapProfiler.addInspectedHeapObject",callback?: (err: Error | null) => void,): void
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).
params: HeapProfiler.AddInspectedHeapObjectParameterType
void
Session.prototype.post(method: "HeapProfiler.addInspectedHeapObject",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.getHeapObjectId",callback?: (err: Error | null,) => void,): void
params: HeapProfiler.GetHeapObjectIdParameterType
void
Session.prototype.post(method: "HeapProfiler.getHeapObjectId",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "HeapProfiler.startSampling",params?: HeapProfiler.StartSamplingParameterType,callback?: (err: Error | null) => void,): void
params: HeapProfiler.StartSamplingParameterType
void
Session.prototype.post(method: "HeapProfiler.startSampling",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "HeapProfiler.stopSampling",callback?: (err: Error | null,params: HeapProfiler.StopSamplingReturnType,) => void,): void
callback: (err: Error | null,params: HeapProfiler.StopSamplingReturnType,) => void
void
Session.prototype.post(method: "HeapProfiler.getSamplingProfile",callback?: (err: Error | null,) => void,): void
Session.prototype.post(method: "NodeTracing.getCategories",callback?: (err: Error | null,params: NodeTracing.GetCategoriesReturnType,) => void,): void
Gets supported tracing categories.
callback: (err: Error | null,params: NodeTracing.GetCategoriesReturnType,) => void
void
Session.prototype.post(method: "NodeTracing.start",params?: NodeTracing.StartParameterType,callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "NodeWorker.sendMessageToWorker",callback?: (err: Error | null) => void,): void
Sends protocol message over session with given id.
params: NodeWorker.SendMessageToWorkerParameterType
void
Session.prototype.post(method: "NodeWorker.sendMessageToWorker",callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "NodeWorker.enable",params?: NodeWorker.EnableParameterType,callback?: (err: Error | null) => void,): void
Instructs the inspector to attach to running workers. Will also attach to new workers as they start
params: NodeWorker.EnableParameterType
void
Session.prototype.post(method: "NodeWorker.detach",params?: NodeWorker.DetachParameterType,callback?: (err: Error | null) => void,): void
Session.prototype.post(method: "NodeRuntime.notifyWhenWaitingForDisconnect",callback?: (err: Error | null) => void,): void
Enable the NodeRuntime.waitingForDisconnect
.
params: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType
void