/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/specs/run/wasm_stack_trace/wasm_stack_trace.js
39 строк
1023 B
Bartek Iwańczuk
fix: format wasm stack traces per W3C spec (#32246)
23 фев 2026, 23:02
Не верифицирован
23 фев 2026, 23:02
578cb26
Код
Авторство
О чём код?
import source unreachableModule from "./unreachable.wasm"; import source stackTraceModule from "./stack_trace.wasm"; // Test 1: Basic unreachable trap - verify wasm stack frame format try { const instance = new WebAssembly.Instance(unreachableModule); instance.exports.main(); } catch (e) { console.log(e.stack); } // Test 2: Wasm -> JS -> throw - verify multi-frame wasm stack try { const instance = new WebAssembly.Instance(stackTraceModule, { env: { js_func() { throw new Error("from JS"); }, }, }); instance.exports.entry(); } catch (e) { console.log(e.stack); } // Test 3: Error.prepareStackTrace sees correct wasm frame toString const origPrepare = Error.prepareStackTrace; Error.prepareStackTrace = (_error, callsites) => { return callsites .map((cs) => cs.toString()) .join("\n"); }; try { const instance = new WebAssembly.Instance(unreachableModule); instance.exports.main(); } catch (e) { console.log(e.stack); } Error.prepareStackTrace = origPrepare;