#Session.prototype.post(method: string,params?: object,): Promise<void>
Posts a message to the inspector back-end.
import { Session } from 'node:inspector/promises';
try {
const session = new Session();
session.connect();
const result = await session.post('Runtime.evaluate', { expression: '2 + 2' });
console.log(result);
} catch (error) {
console.error(error);
}
// Output: { result: { 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.
Parameters #
Return Type #
Promise<void>
#Session.prototype.post(method: "Schema.getDomains"): Promise<Schema.GetDomainsReturnType>
Returns supported domains.
Parameters #
#method: "Schema.getDomains"
Return Type #
Promise<Schema.GetDomainsReturnType>
#Session.prototype.post(method: "Runtime.evaluate",params?: Runtime.EvaluateParameterType,): Promise<Runtime.EvaluateReturnType>
Evaluates expression on global object.
Parameters #
#method: "Runtime.evaluate"
#params: Runtime.EvaluateParameterType
Return Type #
Promise<Runtime.EvaluateReturnType>
#Session.prototype.post(method: "Runtime.awaitPromise",params?: Runtime.AwaitPromiseParameterType,): Promise<Runtime.AwaitPromiseReturnType>
Add handler to promise with given promise object id.
Parameters #
#method: "Runtime.awaitPromise"
#params: Runtime.AwaitPromiseParameterType
Return Type #
Promise<Runtime.AwaitPromiseReturnType>
#Session.prototype.post(method: "Runtime.callFunctionOn",params?: Runtime.CallFunctionOnParameterType,): Promise<Runtime.CallFunctionOnReturnType>
Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
Parameters #
#method: "Runtime.callFunctionOn"
#params: Runtime.CallFunctionOnParameterType
Return Type #
Promise<Runtime.CallFunctionOnReturnType>
#Session.prototype.post(method: "Runtime.getProperties",params?: Runtime.GetPropertiesParameterType,): Promise<Runtime.GetPropertiesReturnType>
Returns properties of a given object. Object group of the result is inherited from the target object.
Parameters #
#method: "Runtime.getProperties"
#params: Runtime.GetPropertiesParameterType
Return Type #
Promise<Runtime.GetPropertiesReturnType>
#Session.prototype.post(method: "Runtime.releaseObject",params?: Runtime.ReleaseObjectParameterType,): Promise<void>
Releases remote object with given id.
Parameters #
#method: "Runtime.releaseObject"
#params: Runtime.ReleaseObjectParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Runtime.releaseObjectGroup",params?: Runtime.ReleaseObjectGroupParameterType,): Promise<void>
Releases all remote objects that belong to a given group.
Parameters #
#method: "Runtime.releaseObjectGroup"
#params: Runtime.ReleaseObjectGroupParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Runtime.runIfWaitingForDebugger"): Promise<void>
#Session.prototype.post(method: "Runtime.enable"): Promise<void>
#Session.prototype.post(method: "Runtime.disable"): Promise<void>
#Session.prototype.post(method: "Runtime.discardConsoleEntries"): Promise<void>
#Session.prototype.post(method: "Runtime.setCustomObjectFormatterEnabled",): Promise<void>
Parameters #
#method: "Runtime.setCustomObjectFormatterEnabled"
#params: Runtime.SetCustomObjectFormatterEnabledParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Runtime.compileScript",params?: Runtime.CompileScriptParameterType,): Promise<Runtime.CompileScriptReturnType>
Compiles expression.
Parameters #
#method: "Runtime.compileScript"
#params: Runtime.CompileScriptParameterType
Return Type #
Promise<Runtime.CompileScriptReturnType>
#Session.prototype.post(method: "Runtime.runScript",params?: Runtime.RunScriptParameterType,): Promise<Runtime.RunScriptReturnType>
Runs script with given id in a given context.
Parameters #
#method: "Runtime.runScript"
#params: Runtime.RunScriptParameterType
Return Type #
Promise<Runtime.RunScriptReturnType>
#Session.prototype.post(method: "Runtime.queryObjects",params?: Runtime.QueryObjectsParameterType,): Promise<Runtime.QueryObjectsReturnType>
Parameters #
#method: "Runtime.queryObjects"
#params: Runtime.QueryObjectsParameterType
Return Type #
Promise<Runtime.QueryObjectsReturnType>
#Session.prototype.post(method: "Runtime.globalLexicalScopeNames",): Promise<Runtime.GlobalLexicalScopeNamesReturnType>
Returns all let, const and class variables from global scope.
Parameters #
#method: "Runtime.globalLexicalScopeNames"
#params: Runtime.GlobalLexicalScopeNamesParameterType
Return Type #
#Session.prototype.post(method: "Debugger.enable"): Promise<Debugger.EnableReturnType>
Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
Parameters #
#method: "Debugger.enable"
Return Type #
Promise<Debugger.EnableReturnType>
#Session.prototype.post(method: "Debugger.disable"): Promise<void>
#Session.prototype.post(method: "Debugger.setBreakpointsActive",): Promise<void>
Activates / deactivates all breakpoints on the page.
Parameters #
#method: "Debugger.setBreakpointsActive"
#params: Debugger.SetBreakpointsActiveParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.setSkipAllPauses",params?: Debugger.SetSkipAllPausesParameterType,): Promise<void>
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
Parameters #
#method: "Debugger.setSkipAllPauses"
#params: Debugger.SetSkipAllPausesParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.setBreakpointByUrl",params?: Debugger.SetBreakpointByUrlParameterType,): Promise<Debugger.SetBreakpointByUrlReturnType>
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.
Parameters #
#method: "Debugger.setBreakpointByUrl"
#params: Debugger.SetBreakpointByUrlParameterType
Return Type #
#Session.prototype.post(method: "Debugger.setBreakpoint",params?: Debugger.SetBreakpointParameterType,): Promise<Debugger.SetBreakpointReturnType>
Sets JavaScript breakpoint at a given location.
Parameters #
#method: "Debugger.setBreakpoint"
#params: Debugger.SetBreakpointParameterType
Return Type #
Promise<Debugger.SetBreakpointReturnType>
#Session.prototype.post(method: "Debugger.removeBreakpoint",params?: Debugger.RemoveBreakpointParameterType,): Promise<void>
Removes JavaScript breakpoint.
Parameters #
#method: "Debugger.removeBreakpoint"
#params: Debugger.RemoveBreakpointParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.getPossibleBreakpoints",): Promise<Debugger.GetPossibleBreakpointsReturnType>
Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.
Parameters #
#method: "Debugger.getPossibleBreakpoints"
#params: Debugger.GetPossibleBreakpointsParameterType
Return Type #
#Session.prototype.post(method: "Debugger.continueToLocation",params?: Debugger.ContinueToLocationParameterType,): Promise<void>
Continues execution until specific location is reached.
Parameters #
#method: "Debugger.continueToLocation"
#params: Debugger.ContinueToLocationParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.pauseOnAsyncCall",params?: Debugger.PauseOnAsyncCallParameterType,): Promise<void>
Parameters #
#method: "Debugger.pauseOnAsyncCall"
#params: Debugger.PauseOnAsyncCallParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.stepOver"): Promise<void>
#Session.prototype.post(method: "Debugger.stepInto",params?: Debugger.StepIntoParameterType,): Promise<void>
Steps into the function call.
Parameters #
#method: "Debugger.stepInto"
#params: Debugger.StepIntoParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.stepOut"): Promise<void>
#Session.prototype.post(method: "Debugger.pause"): Promise<void>
#Session.prototype.post(method: "Debugger.scheduleStepIntoAsync"): Promise<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.
Parameters #
#method: "Debugger.scheduleStepIntoAsync"
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.resume"): Promise<void>
#Session.prototype.post(method: "Debugger.getStackTrace",params?: Debugger.GetStackTraceParameterType,): Promise<Debugger.GetStackTraceReturnType>
Returns stack trace with given stackTraceId
.
Parameters #
#method: "Debugger.getStackTrace"
#params: Debugger.GetStackTraceParameterType
Return Type #
Promise<Debugger.GetStackTraceReturnType>
#Session.prototype.post(method: "Debugger.searchInContent",params?: Debugger.SearchInContentParameterType,): Promise<Debugger.SearchInContentReturnType>
Searches for given string in script content.
Parameters #
#method: "Debugger.searchInContent"
#params: Debugger.SearchInContentParameterType
Return Type #
Promise<Debugger.SearchInContentReturnType>
#Session.prototype.post(method: "Debugger.setScriptSource",params?: Debugger.SetScriptSourceParameterType,): Promise<Debugger.SetScriptSourceReturnType>
Edits JavaScript source live.
Parameters #
#method: "Debugger.setScriptSource"
#params: Debugger.SetScriptSourceParameterType
Return Type #
Promise<Debugger.SetScriptSourceReturnType>
#Session.prototype.post(method: "Debugger.restartFrame",params?: Debugger.RestartFrameParameterType,): Promise<Debugger.RestartFrameReturnType>
Restarts particular call frame from the beginning.
Parameters #
#method: "Debugger.restartFrame"
#params: Debugger.RestartFrameParameterType
Return Type #
Promise<Debugger.RestartFrameReturnType>
#Session.prototype.post(method: "Debugger.getScriptSource",params?: Debugger.GetScriptSourceParameterType,): Promise<Debugger.GetScriptSourceReturnType>
Returns source for the script with given id.
Parameters #
#method: "Debugger.getScriptSource"
#params: Debugger.GetScriptSourceParameterType
Return Type #
Promise<Debugger.GetScriptSourceReturnType>
#Session.prototype.post(method: "Debugger.setPauseOnExceptions",): Promise<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
.
Parameters #
#method: "Debugger.setPauseOnExceptions"
#params: Debugger.SetPauseOnExceptionsParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.evaluateOnCallFrame",): Promise<Debugger.EvaluateOnCallFrameReturnType>
Evaluates expression on a given call frame.
Parameters #
#method: "Debugger.evaluateOnCallFrame"
#params: Debugger.EvaluateOnCallFrameParameterType
Return Type #
#Session.prototype.post(method: "Debugger.setVariableValue",params?: Debugger.SetVariableValueParameterType,): Promise<void>
Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.
Parameters #
#method: "Debugger.setVariableValue"
#params: Debugger.SetVariableValueParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.setReturnValue",params?: Debugger.SetReturnValueParameterType,): Promise<void>
Changes return value in top frame. Available only at return break position.
Parameters #
#method: "Debugger.setReturnValue"
#params: Debugger.SetReturnValueParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.setAsyncCallStackDepth",): Promise<void>
Enables or disables async call stacks tracking.
Parameters #
#method: "Debugger.setAsyncCallStackDepth"
#params: Debugger.SetAsyncCallStackDepthParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.setBlackboxPatterns",): Promise<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.
Parameters #
#method: "Debugger.setBlackboxPatterns"
#params: Debugger.SetBlackboxPatternsParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Debugger.setBlackboxedRanges",): Promise<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.
Parameters #
#method: "Debugger.setBlackboxedRanges"
#params: Debugger.SetBlackboxedRangesParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Console.enable"): Promise<void>
#Session.prototype.post(method: "Console.disable"): Promise<void>
#Session.prototype.post(method: "Console.clearMessages"): Promise<void>
#Session.prototype.post(method: "Profiler.enable"): Promise<void>
#Session.prototype.post(method: "Profiler.disable"): Promise<void>
#Session.prototype.post(method: "Profiler.setSamplingInterval",): Promise<void>
Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
Parameters #
#method: "Profiler.setSamplingInterval"
#params: Profiler.SetSamplingIntervalParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Profiler.start"): Promise<void>
#Session.prototype.post(method: "Profiler.stop"): Promise<Profiler.StopReturnType>
Parameters #
#method: "Profiler.stop"
Return Type #
Promise<Profiler.StopReturnType>
#Session.prototype.post(method: "Profiler.startPreciseCoverage",): Promise<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.
Parameters #
#method: "Profiler.startPreciseCoverage"
#params: Profiler.StartPreciseCoverageParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Profiler.stopPreciseCoverage"): Promise<void>
#Session.prototype.post(method: "Profiler.takePreciseCoverage"): Promise<Profiler.TakePreciseCoverageReturnType>
#Session.prototype.post(method: "Profiler.getBestEffortCoverage"): Promise<Profiler.GetBestEffortCoverageReturnType>
#Session.prototype.post(method: "HeapProfiler.enable"): Promise<void>
#Session.prototype.post(method: "HeapProfiler.disable"): Promise<void>
#Session.prototype.post(method: "HeapProfiler.startTrackingHeapObjects",): Promise<void>
Parameters #
#method: "HeapProfiler.startTrackingHeapObjects"
#params: HeapProfiler.StartTrackingHeapObjectsParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "HeapProfiler.stopTrackingHeapObjects",): Promise<void>
Parameters #
#method: "HeapProfiler.stopTrackingHeapObjects"
#params: HeapProfiler.StopTrackingHeapObjectsParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "HeapProfiler.takeHeapSnapshot",): Promise<void>
Parameters #
#method: "HeapProfiler.takeHeapSnapshot"
#params: HeapProfiler.TakeHeapSnapshotParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "HeapProfiler.collectGarbage"): Promise<void>
#Session.prototype.post(method: "HeapProfiler.getObjectByHeapObjectId",): Promise<HeapProfiler.GetObjectByHeapObjectIdReturnType>
Parameters #
#method: "HeapProfiler.getObjectByHeapObjectId"
#params: HeapProfiler.GetObjectByHeapObjectIdParameterType
Return Type #
#Session.prototype.post(method: "HeapProfiler.addInspectedHeapObject",): Promise<void>
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).
Parameters #
#method: "HeapProfiler.addInspectedHeapObject"
#params: HeapProfiler.AddInspectedHeapObjectParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "HeapProfiler.getHeapObjectId",): Promise<HeapProfiler.GetHeapObjectIdReturnType>
Parameters #
#method: "HeapProfiler.getHeapObjectId"
#params: HeapProfiler.GetHeapObjectIdParameterType
Return Type #
#Session.prototype.post(method: "HeapProfiler.startSampling",params?: HeapProfiler.StartSamplingParameterType,): Promise<void>
Parameters #
#method: "HeapProfiler.startSampling"
#params: HeapProfiler.StartSamplingParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "HeapProfiler.stopSampling"): Promise<HeapProfiler.StopSamplingReturnType>
Parameters #
#method: "HeapProfiler.stopSampling"
Return Type #
Promise<HeapProfiler.StopSamplingReturnType>
#Session.prototype.post(method: "HeapProfiler.getSamplingProfile"): Promise<HeapProfiler.GetSamplingProfileReturnType>
#Session.prototype.post(method: "NodeTracing.getCategories"): Promise<NodeTracing.GetCategoriesReturnType>
Gets supported tracing categories.
Parameters #
#method: "NodeTracing.getCategories"
Return Type #
Promise<NodeTracing.GetCategoriesReturnType>
#Session.prototype.post(method: "NodeTracing.start",params?: NodeTracing.StartParameterType,): Promise<void>
Start trace events collection.
Parameters #
#method: "NodeTracing.start"
#params: NodeTracing.StartParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "NodeTracing.stop"): Promise<void>
#Session.prototype.post(method: "NodeWorker.sendMessageToWorker",): Promise<void>
Sends protocol message over session with given id.
Parameters #
#method: "NodeWorker.sendMessageToWorker"
#params: NodeWorker.SendMessageToWorkerParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "NodeWorker.enable",params?: NodeWorker.EnableParameterType,): Promise<void>
Instructs the inspector to attach to running workers. Will also attach to new workers as they start
Parameters #
#method: "NodeWorker.enable"
#params: NodeWorker.EnableParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "NodeWorker.disable"): Promise<void>
#Session.prototype.post(method: "NodeWorker.detach",params?: NodeWorker.DetachParameterType,): Promise<void>
Detached from the worker with given sessionId.
Parameters #
#method: "NodeWorker.detach"
#params: NodeWorker.DetachParameterType
Return Type #
Promise<void>
#Session.prototype.post(method: "Network.disable"): Promise<void>
#Session.prototype.post(method: "Network.enable"): Promise<void>
#Session.prototype.post(method: "NodeRuntime.enable"): Promise<void>
#Session.prototype.post(method: "NodeRuntime.disable"): Promise<void>
#Session.prototype.post(method: "NodeRuntime.notifyWhenWaitingForDisconnect",): Promise<void>
Enable the NodeRuntime.waitingForDisconnect
.
Parameters #
#method: "NodeRuntime.notifyWhenWaitingForDisconnect"
#params: NodeRuntime.NotifyWhenWaitingForDisconnectParameterType
Return Type #
Promise<void>