Skip to content

Commit d534e57

Browse files
committed
Wrap host objects passes through prepareStackTrace
1 parent e541782 commit d534e57

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

Diff for: lib/setup-sandbox.js

+21-4
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,30 @@ if (typeof OriginalCallSite === 'function') {
276276
return;
277277
}
278278
const newWrapped = (error, sst) => {
279+
const sandboxSst = ensureThis(sst);
279280
if (localArrayIsArray(sst)) {
280-
for (let i=0; i < sst.length; i++) {
281-
const cs = sst[i];
282-
if (typeof cs === 'object' && localReflectGetPrototypeOf(cs) === OriginalCallSite.prototype) {
283-
sst[i] = new CallSite(cs);
281+
if (sst === sandboxSst) {
282+
for (let i=0; i < sst.length; i++) {
283+
const cs = sst[i];
284+
if (typeof cs === 'object' && localReflectGetPrototypeOf(cs) === OriginalCallSite.prototype) {
285+
sst[i] = new CallSite(cs);
286+
}
287+
}
288+
} else {
289+
sst = [];
290+
for (let i=0; i < sandboxSst.length; i++) {
291+
const cs = sandboxSst[i];
292+
localReflectDefineProperty(sst, i, {
293+
__proto__: null,
294+
value: new CallSite(cs),
295+
enumerable: true,
296+
configurable: true,
297+
writable: true
298+
});
284299
}
285300
}
301+
} else {
302+
sst = sandboxSst;
286303
}
287304
return value(error, sst);
288305
};

0 commit comments

Comments
 (0)