Session

external class Session : EventEmitter(source)

The inspector.Session is used for dispatching messages to the V8 inspector back-end and receiving message responses and notifications.

Since

v19.0.0

Constructors

Link copied to clipboard
constructor()

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.

Functions

Link copied to clipboard
fun addListener(event: String, listener: Function<Unit>)

Issued when new console message is added.

Fired when breakpoint is resolved to an actual script and location.

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

fun addListener(event: SessionEvent.DEBUGGER_RESUMED, listener: () -> Unit)

Fired when the virtual machine resumed execution.

Fired when virtual machine fails to parse the script.

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

If heap objects tracking has been started then backend may send update for one or more fragments

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.

Emitted when any notification from the V8 Inspector is received.

This event is fired when the runtime is waiting for the debugger. For example, when inspector.waitingForDebugger is called

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.

Contains an bucket of collected trace events.

Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.

Issued when attached to a worker.

Issued when detached from the worker.

Notifies about a new protocol message received from the session (session ID is provided in attachedToWorker notification).

Sent when new profile recording is started using console.profile() call.

Issued when console API was called.

Issued when unhandled exception was revoked.

Issued when exception was thrown and unhandled.

Issued when new execution context is created.

Issued when execution context is destroyed.

Issued when all executionContexts were cleared in browser

Issued when object should be inspected (for example, as a result of inspect() command line API call).

Link copied to clipboard
fun connect()

Connects a session to the inspector back-end.

Link copied to clipboard

Connects a session to the inspector back-end. An exception will be thrown if this API was not called on a Worker thread.

Link copied to clipboard

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.

Link copied to clipboard
fun emit(event: Symbol, vararg args: Any?): Boolean
fun emit(event: String, vararg args: Any?): Boolean
Link copied to clipboard

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

Link copied to clipboard

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to {@link defaultMaxListeners}.

Link copied to clipboard
fun on(event: String, listener: Function<Unit>)
fun on(event: SessionEvent.HEAPPROFILER_RESETPROFILES, listener: () -> Unit)

Issued when new console message is added.

Fired when breakpoint is resolved to an actual script and location.

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

fun on(event: SessionEvent.DEBUGGER_RESUMED, listener: () -> Unit)

Fired when the virtual machine resumed execution.

Fired when virtual machine fails to parse the script.

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

If heap objects tracking has been started then backend may send update for one or more fragments

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.

Emitted when any notification from the V8 Inspector is received.

This event is fired when the runtime is waiting for the debugger. For example, when inspector.waitingForDebugger is called

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.

Contains an bucket of collected trace events.

fun on(event: SessionEvent.NODETRACING_TRACINGCOMPLETE, listener: () -> Unit)

Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.

Issued when attached to a worker.

Issued when detached from the worker.

Notifies about a new protocol message received from the session (session ID is provided in attachedToWorker notification).

Sent when new profile recording is started using console.profile() call.

Issued when console API was called.

Issued when unhandled exception was revoked.

Issued when exception was thrown and unhandled.

Issued when new execution context is created.

Issued when execution context is destroyed.

Issued when all executionContexts were cleared in browser

Issued when object should be inspected (for example, as a result of inspect() command line API call).

Link copied to clipboard
fun once(event: String, listener: Function<Unit>)

Issued when new console message is added.

Fired when breakpoint is resolved to an actual script and location.

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

fun once(event: SessionEvent.DEBUGGER_RESUMED, listener: () -> Unit)

Fired when the virtual machine resumed execution.

Fired when virtual machine fails to parse the script.

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

If heap objects tracking has been started then backend may send update for one or more fragments

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.

Emitted when any notification from the V8 Inspector is received.

This event is fired when the runtime is waiting for the debugger. For example, when inspector.waitingForDebugger is called

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.

Contains an bucket of collected trace events.

Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.

Issued when attached to a worker.

Issued when detached from the worker.

Notifies about a new protocol message received from the session (session ID is provided in attachedToWorker notification).

Sent when new profile recording is started using console.profile() call.

Issued when console API was called.

Issued when unhandled exception was revoked.

Issued when exception was thrown and unhandled.

Issued when new execution context is created.

Issued when execution context is destroyed.

Issued when all executionContexts were cleared in browser

Issued when object should be inspected (for example, as a result of inspect() command line API call).

Link copied to clipboard

Does nothing.

Disables console domain, prevents further console messages from being reported to the client.

Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification.

Disables debugger for given page.

Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.

Stops on the next JavaScript statement.

Resumes JavaScript execution.

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.

Steps out of the function call.

Steps over the statement.


Disable NodeRuntime events

Enable the NodeRuntime events except by NodeRuntime.waitingForDisconnect.

Gets supported tracing categories.

Stop trace events collection. Remaining collected events will be sent as a sequence of dataCollected events followed by tracingComplete event.

Detaches from all running workers and disables attaching to new workers as they are started.

Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection.

Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code.

Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started.

Disables reporting of execution contexts creation.

Discards collected exceptions and console API calls.

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.

Tells inspected instance to run if it was waiting for debugger to attach.

Returns supported domains.

fun post(method: String, params: Any = definedExternally): Promise<Void>

Posts a message to the inspector back-end.

Continues execution until specific location is reached.

Evaluates expression on a given call frame.

Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.

Returns source for the script with given id.

Returns stack trace with given stackTraceId.

Removes JavaScript breakpoint.

Restarts particular call frame from the beginning.

Searches for given string in script content.

Enables or disables async call stacks tracking.

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.

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.

Sets JavaScript breakpoint at a given location.

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.

Activates / deactivates all breakpoints on the page.

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.

Changes return value in top frame. Available only at return break position.

Edits JavaScript source live.

Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).

Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.

fun post(method: SessionMethod.DEBUGGER_STEPINTO, params: StepIntoParameterType = definedExternally): Promise<Void>

Steps into the function call.

Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).

Enable the NodeRuntime.waitingForDisconnect.

fun post(method: SessionMethod.NODETRACING_START, params: StartParameterType = definedExternally): Promise<Void>

Start trace events collection.

fun post(method: SessionMethod.NODEWORKER_DETACH, params: DetachParameterType = definedExternally): Promise<Void>

Detached from the worker with given sessionId.

fun post(method: SessionMethod.NODEWORKER_ENABLE, params: EnableParameterType = definedExternally): Promise<Void>

Instructs the inspector to attach to running workers. Will also attach to new workers as they start

Sends protocol message over session with given id.

Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.

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.

Add handler to promise with given promise object id.

Calls function with given declaration on the given object. Object group of the result is inherited from the target object.

Compiles expression.

Evaluates expression on global object.

Returns properties of a given object. Object group of the result is inherited from the target object.

Returns all let, const and class variables from global scope.

Releases remote object with given id.

Releases all remote objects that belong to a given group.

Runs script with given id in a given context.

Link copied to clipboard
fun prependListener(event: String, listener: Function<Unit>)

Issued when new console message is added.

Fired when breakpoint is resolved to an actual script and location.

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

Fired when the virtual machine resumed execution.

Fired when virtual machine fails to parse the script.

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

If heap objects tracking has been started then backend may send update for one or more fragments

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.

Emitted when any notification from the V8 Inspector is received.

This event is fired when the runtime is waiting for the debugger. For example, when inspector.waitingForDebugger is called

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.

Contains an bucket of collected trace events.

Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.

Issued when attached to a worker.

Issued when detached from the worker.

Notifies about a new protocol message received from the session (session ID is provided in attachedToWorker notification).

Sent when new profile recording is started using console.profile() call.

Issued when console API was called.

Issued when unhandled exception was revoked.

Issued when exception was thrown and unhandled.

Issued when new execution context is created.

Issued when execution context is destroyed.

Issued when all executionContexts were cleared in browser

Issued when object should be inspected (for example, as a result of inspect() command line API call).

Link copied to clipboard
fun prependOnceListener(event: String, listener: Function<Unit>)

Issued when new console message is added.

Fired when breakpoint is resolved to an actual script and location.

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

Fired when the virtual machine resumed execution.

Fired when virtual machine fails to parse the script.

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

If heap objects tracking has been started then backend may send update for one or more fragments

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.

Emitted when any notification from the V8 Inspector is received.

This event is fired when the runtime is waiting for the debugger. For example, when inspector.waitingForDebugger is called

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.

Contains an bucket of collected trace events.

Signals that tracing is stopped and there is no trace buffers pending flush, all data were delivered via dataCollected events.

Issued when attached to a worker.

Issued when detached from the worker.

Notifies about a new protocol message received from the session (session ID is provided in attachedToWorker notification).

Sent when new profile recording is started using console.profile() call.

Issued when console API was called.

Issued when unhandled exception was revoked.

Issued when exception was thrown and unhandled.

Issued when new execution context is created.

Issued when execution context is destroyed.

Issued when all executionContexts were cleared in browser

Issued when object should be inspected (for example, as a result of inspect() command line API call).

Link copied to clipboard

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.