Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim: update Error.prepareStackTrace shim
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhorton committed Apr 12, 2018
1 parent 06d2b9c commit d5d61a5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion deps/chakrashim/lib/chakra_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,17 @@
function stackGetter() {
if (!isPrepared) {
const prep = Error.prepareStackTrace || prepareStackTrace;
stackSetter(prep(err, ensureStackTrace()));

// Prep can be re-entrant, of sorts, with regards to setting err.stack vs returning what err.stack should be
// We are trying to emulate the following behavior:
// Error.prepareStackTrace = function (err, frames) { err.stack = 1 } -> err.stack should be 1
// Error.prepareStackTrace = function (err, frames) { console.log("Called prepare") } -> err.stack should be undefined
// Error.prepareStackTrace = function (err, frames) { return 2 } -> err.stack should be 2
// Error.prepareStackTrace = function (err, frames) { err.stack = 1; return 2; } -> err.stack should be *1*
const preparedStack = prep(err, ensureStackTrace());
if (!isPrepared) {
stackSetter(preparedStack);
}
}

return currentStack;
Expand Down

0 comments on commit d5d61a5

Please sign in to comment.