Skip to content

Commit f17b949

Browse files
committed
doc: update vm.runInDebugContext() example
The debugger needs to be active now before one is allowed to query the list of scripts. Replace the example with one that works without installing a debug event listener first. Fixes: #4862 PR-URL: #6757 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent eb089e7 commit f17b949

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/api/vm.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,10 @@ a separate process.
221221
context. The primary use case is to get access to the V8 debug object:
222222

223223
```js
224+
const vm = require('vm');
224225
const Debug = vm.runInDebugContext('Debug');
225-
Debug.scripts().forEach((script) => { console.log(script.name); });
226+
console.log(Debug.findScript(process.emit).name); // 'events.js'
227+
console.log(Debug.findScript(process.exit).name); // 'internal/process.js'
226228
```
227229

228230
Note that the debug context and object are intrinsically tied to V8's debugger

0 commit comments

Comments
 (0)