-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
5.8mb contents of obfuscated wasm module printed when exception thrown elsewhere in program #43462
Comments
Hi I am running into what seems like the exact same problem. I added some context including a very simple reproducible example in the emscripten thread here: emscripten-core/emscripten#17228 (comment) @dvtate did you ever find a workaround for this? |
@lastmjs IIRC the problem occurs when there's an uncaught exception. So maybe if you catch all the exceptions (and maybe print them differently?) |
Unfortunately that does not help, I've tried to do this for example like this:
The wall of text still comes. The best I have found so far is to use |
BTW @RedYetiDev I'm not sure how much this issue has to do with Wasm. The binaryen.js library is a very large file of minified JS, and that is what is printed to the terminal. |
This comment was marked as outdated.
This comment was marked as outdated.
Based on the information in the other issues and what I've found, the root of the problem seems to be with Node.js (for example: AssemblyScript/binaryen.js#94 (comment)). |
@RedYetiDev the problem is that nodejs always prints out the entire line that the error originates from. For minified code this single line could be very, very big (and unreadable). Node.js should truncate code snippets printed out in error messages. |
That seems to be working as intended, but I'd love a second opinion. |
Why is dumping an entire minified file into the stack trace considered as Node.js "working as intended"? "Working as intended" should be truncating the line because nobody needs the entire source code to be print out every stack trace. |
Keep in mind this is all my opinion, so someone else could always disagree. The way I see it is: if the source code is minified into one line, that's the line that will be printed. The stack trace always printed where the error came from. Whether the error can from a normal line(s) or a minified one, the line(s) where it came from will always be printed. |
FWIW const fs = require('fs');
// Setup
fs.writeFileSync('index.js',
`"${'a'.repeat(10000)}"; throw new Error("Error!")`
)
// Run
require('./index.js') |
How is this helpful? When would a Node.js developer ever need a line tens of thousands of characters long printed in their terminal as part of a stack trace? It doesn't help with debugging (and actually impedes it), which defeats the point of a stack trace. |
If you think you have an improvement, feel free to submit a PR. |
Correction: the error doesn't even originate from the line that's reported. In fact, as you can see in @dvtate's original example and @lastmjs's similar example, the error is thrown in a completely separate file.
To say that users would like to see multiple screenfuls of minified output is a dubious assertion, but that's not the real issue here. An error is being thrown from one file, but the line that's printed is from another file entirely (the stack trace is correct though). The fact that the line happens to be megabytes long is just a further inconvenience. Anyways, in case it's useful, I'd like to mention that |
It appears we were discussing two seperate things, maybe there was a miscommunication.
|
FWIW according to the stack that I tested, the error is from:
|
It looks like this is the issue: process.on("uncaughtException", error => {
throw error // this line probably shouldn't be printed!
})
throw new Error("hey") // this line isn't what's printed... Running this prints:
This makes me wonder if this behavior is intentional (maybe it's a matter of preference, but I'd like the printed line to be based on the stack trace)... In any case, our particular issue will be resolved soon anyway, by removing the |
So if I understand correctly, the minified file (binaryen) is hooking into the |
@RedYetiDev That's correct, but this is being done through Emscripten's |
As you showed, I'm not saying this won't change, just that it's not (IMO) a bug, but rather a feature request, so feel free to open a new issue. |
So...could/should binaryen fix this? |
Whomever added the |
@lastmjs the next nightly release will fix your issue |
Version
v18.3.0
Platform
Linux archbook 5.18.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 09 Jun 2022 16:14:10 +0000 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Please see this issue thread: emscripten-core/emscripten#17228
A realistic example is done as follows:
How often does it reproduce? Is there a required condition?
Consistently reproducable. I even remember experienceing this exact bug as far back as 2020 (nodejs v14+)
What is the expected behavior?
I'm assuming that it's importing the module concurrently with the main thread if that's the case than on error only the thread that errored should have it's code highlighted, or at least the code highlighted code should be truncated to where it doesn't take several seconds to print
What do you see instead?
5.8mb of obfuscated javascript which burries the debugging message I had written
Additional information
Relevant thread: emscripten-core/emscripten#17228
The text was updated successfully, but these errors were encountered: