-
Notifications
You must be signed in to change notification settings - Fork 7.3k
"Pause on uncaught exceptions" not pausing on "undefined is not a function" #7439
Comments
@tgirardi I had some time to investigate this issue. Here's what I found out so far. Node-inspector can't find the mapping between where the exception event occurred and any actual source file that was loaded. The reason is that, in the case of the call of an undefined function, the exception is thrown by a builtin
in When accessing a property of an undefined object, the exception event that node-inspector receives from the debugger has the right script id and thus node-inspector can pause the debuggee. It seems that V8 generates the code that handle function calls in memory (see code around @indutny @trevnorris @tjfontaine Any idea? |
Also /cc @bajtos |
Not familiar with node-inspector's internals, but the following does work to properly halt execution on the tip of v0.12: process.on('uncaughtException', function() {
process._rawDebug('HERE');
debugger;
});
var def;
def(); And run with:
|
@trevnorris With your code example, node-inspector receives two events that could make it pause the debuggee:
This event is associated with a source line that is in
What I think is not working as expected by @tgirardi is the first step. Maybe the event generated at step one used to be associated with the actual source file of the call site, or maybe node-inspector changed how it behaves when the event's source file is not found in its source maps. It would be great to have some feedback about this from @bajtos. |
@tgirardi I realize that I may have assumed too quickly that this feature used to work for previous versions of node-inspector/node. However, after testing several different combinations of node/node-inspector, I have yet to find one for which this feature works. Do you know if pausing the debuggee on a call to an undefined function has ever worked? |
@trevnorris , @misterdjules , this issue is relative to #5713. TryCatch try_catch;
try_catch.setVerbose(true); Node Inspector internals uses nothing special for handling uncaught errors, it only listens on In other words I think that there is missed one or more |
@3y3 "undefined is not a function" is not emitted as is, but an exception event that comes from the call to the undefined function is sent by v8 and received by node-inspector. You should be able to see it by running node-inspector with the When the call to the undefined function generates an exception, I was able to confirm using lldb that its "verbose" flag is set to true. So in my opinion, the issue doesn't come from the fact that some TryCatch blocks don't have the verbose flag set to true. However, if you read the implementation of
I will investigate further down this path when I have some time, but it'll be a slow process since I'm quite new to v8. |
@misterdjules , ok, excuse me, I started Inspector with help of node-debug, therefor I missed all inspector log messages. This issue can be closed. |
@3y3 No problem, thank you very much for helping solve this issue! |
@misterdjules Thank you very much for investigating this issue, your conclusions are correct. I submitted a patch for Node Inspector to fix the problem there (node-inspector/node-inspector#418). @trevnorris You can close this issue. |
Note: this issue was reproduced using node-inspector. I also posted it on node-inspector's issue tracker (node-inspector/node-inspector#344) and they suggested me to post it here also as it is not clear if this is a node issue or a node-inspector issue.
While using node-inspector and having "Pause on uncaught exception" option activated, the debugger won't stop at an exception of type "TypeError: undefined is not a function".
How to reproduce:
Expected result:
The debugger pauses at the line where the exception is going to occur.
Actual result:
The debugger doesn't pause at the line where the exception occurs. The terminal shows that the exception occurred.
Tested under:
Code used for my tests:
Notes:
I tested with another type of uncaught exception and the debugger did pause. It was a "TypeError: Cannot read property 'prop' of undefined" exception caused by code:
var undef; undef.prop;
@bajtos took a look at the issue and could also reproduce it, but he is short on time at the moment in order to investigate it further.
The text was updated successfully, but these errors were encountered: