How to track down an uncaught error in rxjs / zone.js?

556 views
Skip to first unread message

Partap Davis

unread,
Jan 13, 2017, 7:00:14 PM1/13/17
to Angular
I'm getting an uncaught TypeError that is triggered in SafeSubscriber.prototype._tryOrUnsub() 
...looks like that is defined in rxjs/Subscriber ...

Problem is that the stack gives me no idea what code is triggering the exception:

SafeSubscriber.__tryOrUnsub    build.js:4646
SafeSubscriber.next            build.js:4591
Subscriber._next               build.js:4544
Subscriber.next                build.js:4508
Subject.next                   build.js:4980
EventEmitter.emit              build.js:5165
NgZone.triggerError            build.js:5533
inner
.inner.fork.onHandleError build.js:5494
ZoneDelegate.handleError       zone.js:246
Zone.runTask                   zone.js:154
ZoneTask.invoke                zone.js:345

None of the functions in the call stack are from my code...I don't know how zone.js works...
iirc, it is responsible for triggering async actions...so probably something in a template?

The problem is compounded by the fact that this error only happens when I run my app in a browser on an embedded system, so my debugging tools are limited.
I can connect with chrome devtools, but it takes ages to respond to any input, if it ever actually does...half the time it just disconnects without showing me anything.

Is there something I can look for in the scopes on the call stack that will give me a hint as to what is triggering the exception?

Thanks
-partap

Sander Elias

unread,
Jan 16, 2017, 12:32:56 AM1/16/17
to Angular
Hi Partap,

This is a real issue. If you find a (partial) answer, please share! This is also my main gripe with Angular at the moment, that the errors are usually completely useless. 

Regards
Sander 

Sander Elias

unread,
Jan 16, 2017, 12:34:31 AM1/16/17
to Angular
I just found a tip, that might help you a tad. didn't test (yet)

If you're running zone.js 0.7.5, try rolling back to 0.7.4 and trying again.  The error message should be better.

 

Partap Davis

unread,
Jan 19, 2017, 12:51:41 AM1/19/17
to Angular
I tried rolling it back...didn't help me much, as you'll see...

I also looked into what Zones actually do and how they work, and it's pretty cool.  It looked like they should be helping me in this case, especially with long-stack-trace-zone.js.

After I included the long stack trace support, it seemed I was actually getting *more* errors, and even less helpful stack traces...so I disabled them.  
Somewhere along the line, I removed more debug and error logging and my app seemed to suddenly run without errors.

Anyways, I think I've finally tracked down what this particular error was coming from after it started popping up again, and it turns out that I was actually triggering the exceptions *in* my error handlers, simply by accessing error.stack!  

In this particular browser, Error.prototype.stack is implemented as a property with native code get and set functions, rather than as a simple string.  Problem is, calling the getter appears to consistently trigger a TypeError internally.

Back in zone.js, the global Error constructor is replaced with ZoneAwareError...and the constructor for ZoneAwareError starts with:

        // Save original stack trace
        error
.originalStack = error.stack;



So, right away, that line throws a TypeError... I'm guessing this new TypeError is probably shadowing every error thrown within my Angular app, which is less than ideal.

Frankly, I'm surprised anything is working at all...I guess it must somehow fall back to the browser's native Error rather than recursing into ZoneAwareError.  Not sure how that works...

At this point I'm just hoping to get some support from the hardware vendor. The SDK came with an NDA...which I haven't actually seen, but just to be safe, I'd rather not reveal who the vendor is at this point... 
Reply all
Reply to author
Forward
0 new messages