module: improve detection try catch
This refactors the try
/catch
added in #52093 to happen in C++, so that the rethrown error preserves the same origin, source arrow and source map-translated stack trace. This gets us much closer to being able to unflag --experimental-detect-module
and have all the tests pass. The C++ was written by @targos
There’s currently only one test failing on this branch, and I’d love some help getting it to pass. ./node test/parallel/test-debugger-exceptions.js
is failing because in node inspect
, for some reason the inspector sees the exception as being thrown by the new TryCatchRethrow
rather than the rethrown exception. If anyone can figure out why this is and what we can do about it, I would be very grateful. cc @jkrems @nodejs/loaders @nodejs/inspector @nodejs/v8-inspector