Skip to content

Commit 50f02bd

Browse files
bnoordhuisMyles Borins
authored and
Myles Borins
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 773ea20 commit 50f02bd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/api/vm.markdown

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

214214
```js
215+
const vm = require('vm');
215216
const Debug = vm.runInDebugContext('Debug');
216-
Debug.scripts().forEach((script) => { console.log(script.name); });
217+
console.log(Debug.findScript(process.emit).name); // 'events.js'
218+
console.log(Debug.findScript(process.exit).name); // 'internal/process.js'
217219
```
218220

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

0 commit comments

Comments
 (0)