File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -564,6 +564,9 @@ changes:
564564Returns an array of call site objects containing the stack of
565565the caller function.
566566
567+ Unlike accessing an ` error.stack ` , the result returned from this API is not
568+ interfered with ` Error.prepareStackTrace ` .
569+
567570``` mjs
568571import { getCallSites } from ' node:util' ;
569572
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+ const assert = require ( 'node:assert' ) ;
5+ const { getCallSites } = require ( 'node:util' ) ;
6+
7+ // Asserts that util.getCallSites() does not invoke
8+ // Error.prepareStackTrace.
9+
10+ Error . prepareStackTrace = common . mustNotCall ( ) ;
11+
12+ const sites = getCallSites ( 1 ) ;
13+ assert . strictEqual ( sites . length , 1 ) ;
14+ assert . strictEqual ( sites [ 0 ] . scriptName , __filename ) ;
You can’t perform that action at this time.
0 commit comments