-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken exception stack trace in async arrow function #157
Comments
So it seems that async arrow functions cause problems if they were called from another file other than where they defined, not only if they are called from another context or another v8 instance. My position on this issue is that we should not fix it here in bytenode. Especially if the fix needs gigantic libraries and dependencies. Also, the developer can easily add a simple transformation to his project. Most developers nowadays use huge setups that have more than enough to transpile arrow async functions into usual functions. At best, we can check if the source code contains async arrow functions and warn the user if this is true. Finally, as I mentioned before, |
According to my test, hello-export.js module.exports.makeSomeError = async () => {
''.a();
};
module.exports.printSource = function() {
console.log('source code: ', module.exports.makeSomeError.toString());
} main.js const hello = require('./hello-export.js');
hello.printSource()
hello.makeSomeError() pkg(v5.3.3) config "pkg": {
"targets": [
"node14-linux-x64"
],
"outputPath": "dist"
} Run binary
Also, my demo for soucemap seems to work |
Env
Node: v14.17.2
OS: Linux
Bytenode: 1.3.3
Demo
hello-export.js
main.js
Run
Output
Note: if replace async arrow function with
async function() {}
, the code works fine.I read about https://github.com/bytenode/bytenode/issues/106, but i think it is not about puppeteer or Electron, v8 has some bugs here
In node 14.18 source code deps/v8/src/parsing/parser.cc line 918, i found this
V8 relies on source code to determine whether a function is async arrow function.
So it's dead end here.
I think the best solution is to generate some kind of sourcemap for jsc, which includes function outline (i.e function statement)
if i got some time , i will work on it.
P.S.
I have written some homebrew bytecode libs and articles, which are inspired by bytenode, Big Thanks to You.
https://github.com/Nihiue/little-byte
It's in Chinese, but i think google translation will work :D.
https://translate.google.com/translate?js=n&sl=chinese&tl=en&u=https://github.com/Nihiue/little-byte
The text was updated successfully, but these errors were encountered: