0

I am trying to collect crash logs for my WebAssembly application. It's built with emscripten, everything is served from the same domain, testing in Chrome. In the developer console I see a proper error with stack trace when a crash occurs, I'd like to capture this and send it to a server.

Instead I am only getting "Script error." passed to window.onerror() and the fifth parameter is null. This is supposed to happen when violating the same-origin policy (linked question is only about javascript, does not talk about this WebAssembly-specific problem.) Errors occurring in the .js file don't have this problem, only webassembly runtime errors.

I added the crossorigin attribute to the .js file generated by emscripten. The site is running in secure context, the Response object passed to WebAssembly.instantiateStreaming() (in the emscripten-generated .js file) has "basic" as its .type, so as I understand it has no restrictions on what can be done with it. "Access-Control-Allow-Origin" header is set to "*".

For some weird reason I managed to get the full error with stack trace exactly once, so it is apparently possible, but seemingly doing everything the same way I can't get it to work again.

How can this be solved?

janb
  • 69
  • 6

1 Answers1

0

instantiateStreaming is promised based so maybe try window.addEventListener('unhandledrejection')?

sbc100
  • 2,619
  • 14
  • 11
  • I have a handler for unhandledrejection, it isn't called. Also the errors that I want to handle happen while running the wasm code, not when instantiateStreaming() happens. – janb May 30 '22 at 13:12