improve sandbox resilience against process aborts

This commit is contained in:
alexlamsl 2021-12-07 02:13:42 +08:00
parent d2e7c4af20
commit f292219811

View File

@ -295,7 +295,7 @@ function run_code_exec(code, toplevel, timeout) {
} catch (e) {} } catch (e) {}
} }
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg); var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
if (!match) return details || new Error(msg); if (!match) return details || new Error("Script execution aborted.");
var ex = new global[match[1]](match[2]); var ex = new global[match[1]](match[2]);
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3]; ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
if (typeof details == "object") { if (typeof details == "object") {