Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ changes:
Returns an array of call site objects containing the stack of
the caller function.

Unlike accessing an `error.stack`, the result returned from this API is not
interfered with `Error.prepareStackTrace`.

```mjs
import { getCallSites } from 'node:util';

Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-util-getcallsites-preparestacktrace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const common = require('../common');
const assert = require('node:assert');
const { getCallSites } = require('node:util');

// Asserts that util.getCallSites() does not invoke
// Error.prepareStackTrace.

Error.prepareStackTrace = common.mustNotCall();

const sites = getCallSites(1);
assert.strictEqual(sites.length, 1);
assert.strictEqual(sites[0].scriptName, __filename);
Loading