Skip to content

Commit

Permalink
check error stack availability before cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
BasixKOR committed Sep 15, 2021
1 parent 73b5186 commit f02e40c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core-js/internals/structured-clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ module.exports = function structuredCloneInternal(weakmap, value) {
break;
case 'Error':
// Attempt to clone the stack.
if (!Object.prototype.hasOwnProperty.call(Error.prototype, 'stack')) break;
if (
!Object.prototype.hasOwnProperty.call(value, 'stack') && // Chrome, Safari
!Object.prototype.hasOwnProperty.call(Error.prototype, 'stack') // Firefox
) break;
try {
cloned.stack = structuredCloneInternal(weakmap, value.stack);
} catch (error) {
Expand Down

0 comments on commit f02e40c

Please sign in to comment.