[Javascript] UnhandledRejection Timeout

We are getting a number of UnhandledRejection’s with an Error value of Timeout.

We have enabled the ExtraErrorData integration, and other errors include the entire error object and stack traces. However these errors contain nothing but the name ‘Timeout’, and contain no stack trace at all.

Is there any way to get more information about the origin of these errors?

My best guess would be that something in your code throwing strings instead of proper Error objects that capture the stack trace. This slide and the whole deck tells the story pretty well: https://speakerdeck.com/benvinegar/getting-the-most-out-of-javascript-errors?slide=33

For a useful suggestion: search your code base for throw 'Timeout' or reject('Timeout') and you can probably work backwards from there or replace them with throw new Error('Timeout') and reject(new Error('Timeout')) respectively to get stack traces and more.

Hope this helps!

@BYK Thanks for you reply. I’ve searched through our own code and all compiled third-party code, looking for ‘Timeout’, “Timeout” and Timeout. This string isn’t thrown or passed to reject() anywhere.

The only thing I can think of is that this is coming from a third-part lib that we are loading at runtime (Analytics, Intercom etc).

@Pedr - yeah that’s the most probable scenario. I did a quick search on GitHub and the situation doesn’t look bright. I’ve even seen libraries using a cached Error object which would give you an incorrect stack trace. Anyway, I’ve found a library called xhrify that does exactly this: https://github.com/edicury/xhrify/blob/master/xhrify.js#L56

If you have that in your repo, it may be the culprit. Once you find the library, I’d recommend submitting a PR to them to fix the issue for everyone. Feel free to share it here too in case anyone suffers from the same problem.

Thanks. I’m in the process of whitelisting only our own URLS. Hopefully that will banish it.

1 Like