Skip to content

Commit

Permalink
Merge pull request #961 from postmanlabs/feature/fix-prepareStackTrace
Browse files Browse the repository at this point in the history
Fixed custom Error.prepareStackTrace
  • Loading branch information
codenirvana authored Oct 19, 2023
2 parents 5e890c2 + 2d06795 commit 6340ba1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
unreleased:
fixed bugs:
- GH-961 Fixed `Error.prepareStackTrace` to prevent stack trace pollution

4.2.7:
date: 2023-08-03
chores:
Expand Down
6 changes: 3 additions & 3 deletions lib/sandbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
// define custom Error.prepareStackTrace
Object.defineProperty(Error, 'prepareStackTrace', {
value: function (error, structuredStackTrace) {
const errorString = String(error);
let errorString = `Error: ${error && error.message}`;

if (Array.isArray(structuredStackTrace) && structuredStackTrace.length) {
return `${errorString}\n at ${structuredStackTrace.join('\n at ')}`;
for (let i = 0; i < (structuredStackTrace && structuredStackTrace.length); i++) {
errorString += `\n at ${structuredStackTrace[i]}`;
}

return errorString;
Expand Down

0 comments on commit 6340ba1

Please sign in to comment.