mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
* Set a default value for `Error.prepareStackTrace` to align with Node * Ensure we never set negative line/column numbers in error.stack (#8656) * fix(windows): fix macros (#8653) * fix macro tests * path format options * remove failing comment * fix buffer toString memcpy length * Ensure we never set negative line/column numbers in error.stack --------- Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
24 lines
758 B
JavaScript
Generated
24 lines
758 B
JavaScript
Generated
// @bun
|
|
// This tests that Error.prepareStackTrace behaves the same when it is set to undefined as when it was never set.
|
|
const orig = Error.prepareStackTrace;
|
|
|
|
Error.prepareStackTrace = (err, stack) => {
|
|
return orig(err, stack);
|
|
};
|
|
|
|
const err = new Error();
|
|
Error.captureStackTrace(err);
|
|
const stack = err.stack;
|
|
|
|
Error.prepareStackTrace = undefined;
|
|
const err2 = new Error();
|
|
Error.captureStackTrace(err2);
|
|
const stack2 = err2.stack;
|
|
|
|
const stackIgnoringLineAndColumn = stack2.replaceAll(":16:2", "N");
|
|
const stack2IgnoringLineAndColumn = stack.replaceAll(":11:2", "N");
|
|
if (stackIgnoringLineAndColumn !== stack2IgnoringLineAndColumn) {
|
|
console.log(stackIgnoringLineAndColumn, stack2IgnoringLineAndColumn);
|
|
throw new Error("Stacks are different");
|
|
}
|