HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
CrabDude
trycatch
JavaScript2012–2014
CrabDude / trycatch

trycatch

An asynchronous domain-based exception handler with long stack traces for node.js

2Distinct people
8Mentions
1Explicit recommenders
245GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

An asynchronous domain-based exception handler with long stack traces for node.js

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

I recommend adding my async trycatch library with long stack traces: https://github.com/CrabDude/trycatch.

eldude used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month8 dated mentions

Observed mentions: 2012-07-17 04:45:27 UTC to 2014-09-12 15:33:06 UTC.

01232012-07-01 00:00:00 UTC to 2012-08-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsJul 20122012-08-01 00:00:00 UTC to 2012-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-09-01 00:00:00 UTC to 2012-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-10-01 00:00:00 UTC to 2012-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2012-11-01 00:00:00 UTC to 2012-12-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2012-12-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-01-01 00:00:00 UTC to 2013-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-02-01 00:00:00 UTC to 2013-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-03-01 00:00:00 UTC to 2013-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-04-01 00:00:00 UTC to 2013-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-05-01 00:00:00 UTC to 2013-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-06-01 00:00:00 UTC to 2013-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-07-01 00:00:00 UTC to 2013-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-08-01 00:00:00 UTC to 2013-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsAug 20132013-09-01 00:00:00 UTC to 2013-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-10-01 00:00:00 UTC to 2013-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-01 00:00:00 UTC to 2013-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-01-01 00:00:00 UTC to 2014-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-02-01 00:00:00 UTC to 2014-03-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2014-03-01 00:00:00 UTC to 2014-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-04-01 00:00:00 UTC to 2014-05-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2014-05-01 00:00:00 UTC to 2014-06-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2014-06-01 00:00:00 UTC to 2014-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-07-01 00:00:00 UTC to 2014-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-08-01 00:00:00 UTC to 2014-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-09-01 00:00:00 UTC to 2014-10-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsSep 2014

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Jul 20122012-07-01 00:00:00 UTC2012-08-01 00:00:00 UTC101
Aug 20122012-08-01 00:00:00 UTC2012-09-01 00:00:00 UTC000
Sep 20122012-09-01 00:00:00 UTC2012-10-01 00:00:00 UTC000
Oct 20122012-10-01 00:00:00 UTC2012-11-01 00:00:00 UTC000
Nov 20122012-11-01 00:00:00 UTC2012-12-01 00:00:00 UTC110
Dec 20122012-12-01 00:00:00 UTC2013-01-01 00:00:00 UTC000
Jan 20132013-01-01 00:00:00 UTC2013-02-01 00:00:00 UTC000
Feb 20132013-02-01 00:00:00 UTC2013-03-01 00:00:00 UTC000
Mar 20132013-03-01 00:00:00 UTC2013-04-01 00:00:00 UTC000
Apr 20132013-04-01 00:00:00 UTC2013-05-01 00:00:00 UTC000
May 20132013-05-01 00:00:00 UTC2013-06-01 00:00:00 UTC000
Jun 20132013-06-01 00:00:00 UTC2013-07-01 00:00:00 UTC000
Jul 20132013-07-01 00:00:00 UTC2013-08-01 00:00:00 UTC000
Aug 20132013-08-01 00:00:00 UTC2013-09-01 00:00:00 UTC000
Sep 20132013-09-01 00:00:00 UTC2013-10-01 00:00:00 UTC000
Oct 20132013-10-01 00:00:00 UTC2013-11-01 00:00:00 UTC000
Nov 20132013-11-01 00:00:00 UTC2013-12-01 00:00:00 UTC000
Dec 20132013-12-01 00:00:00 UTC2014-01-01 00:00:00 UTC000
Jan 20142014-01-01 00:00:00 UTC2014-02-01 00:00:00 UTC000
Feb 20142014-02-01 00:00:00 UTC2014-03-01 00:00:00 UTC101
Mar 20142014-03-01 00:00:00 UTC2014-04-01 00:00:00 UTC000
Apr 20142014-04-01 00:00:00 UTC2014-05-01 00:00:00 UTC303
May 20142014-05-01 00:00:00 UTC2014-06-01 00:00:00 UTC101
Jun 20142014-06-01 00:00:00 UTC2014-07-01 00:00:00 UTC000
Jul 20142014-07-01 00:00:00 UTC2014-08-01 00:00:00 UTC000
Aug 20142014-08-01 00:00:00 UTC2014-09-01 00:00:00 UTC000
Sep 20142014-09-01 00:00:00 UTC2014-10-01 00:00:00 UTC101

What Hacker News says

8 sources
Another upcoming method to avoid callback hell that is my personal favorite is harmony generators and yield. Reminds me so much of C# async. Two great libraries can handle it today on beta versions of node [1,2]. I have only used suspend. See this gist for comparison https://gist.github.com/codystebbins/a2c354d25ce28879bfe1. With generators try/catch can be used, avoiding a lot of the redundant error handling. Crabdude's library can avoid the overhead of try/catch [3]. And if developers want static typing, they should check out TypeScript. Works great with node. [1] https://github.com/jmar777/suspend [2] https://github.com/visionmedia/co [3] https://github.com/CrabDude/trycatch
In Why Node.js is becoming the go-to technology in the Enterprise
> They are nestable trycatch is nestable as well. > they can store arbitrary values, timers Nice. I am currently decoupling trycatch's hooking layer to allow for this arbitrarily[1]. The continuation-local-storage library[2] allows for this functionality as well. > intercept microtasks Care to elaborate? > wrap closures to be associated with the Zone Yup, similar to domains, though I do wonder when this is necessary? One use case that came up with trycatch was finally support, or the need to exit the current domain/trycatch context.[3] Lastly, there's one consistent failure I see in all these domain-like, async listener-like, long-stack-trace, event-source modules and that's long-lived resources or how they incorrectly handle EventEmitter handler's context[4], with the core issue being the boundary at which the hook is applied (From Trevo
Read the rest
r Norris' comment): After thinking this over, it occurred to me that trycatch is a top down approach. Whereas AsyncListener is bottom up. Long story short, things like keep-alive sockets will retain a domain/context/zone(?) and their handlers will be called with the incorrect context. Do you fix this in your zone.js implementation? [1] https://github.com/CrabDude/trycatch/issues/38 [2] https://github.com/othiym23/node-continuation-local-storage [3] https://github.com/CrabDude/trycatch/issues/37 [4] https://github.com/CrabDude/trycatch/issues/32
In Comparing Node.js Promises, Try/Catch, Angular Zone.js and Zone
A major limitation of using try/catch is that V8 will DEOPT your function call, which can be a 5-10x performance hit (to the current closure). The best way to avoid this is with a silly hack: function trycatchit(fn, that, args) { try { return fn.apply(that, args) } catch(e) { return e } } var value = trycatchit(fn, null, 'someValue') if (value instanceof Error) { ... } Really though, you should just let co or whatever generator library you're using catch the error and rethrow it (or pass it to a callback) or be mindful to minimize your error handling. [1] https://github.com/CrabDude/trycatch/blob/master/lib/trycatc...
In Comparing Node.js Promises, Try/Catch, Angular Zone.js and Zone
> Up until recently that was pretty much all we had. [Edit: see my comment below[0]. This is more a coincidence of wording than a StrongLoop marketing line] When StrongLoop talked at my south bay node.js meetup group, BayNode[1], at Hacker Dojo last month, they demoed Zone.js. Before demoing though, they asked if anyone in the group had "solved this" to which I made it very clear that, "Yes, I did about 2 years ago with trycatch[2]." Their response could be summed up as, "Oh?" Long story short, not only does my async try/catch library solve this, I can say with near certainty that it solves it in a better, more consistent, more tested, more battle proven, more performant manner. We use trycatch at LinkedIn and have not had to worry about async error handling since. Additionally, adding it to any control-flow of your choice is trivial, as
Read the rest
I have done with my stepup library[3]. Further, their main bullet-points are about enforcing the callback contract, something EVERY control-flow library should be doing, (I previously went into more detail here[4]) and the primary reason for the popularity of promises since they formalized this contract. In fact, I teach these core contract rules in my monthly week-long node.js bootcamp I give here at LinkedIn[5], and the only thing they have to do with control-flow is that your control-flow library of choice should enforce them, as stepup and promises do. I do add a few rules: * Function that takes 2 arguments: 1. first argument is an error, 2. second argument is the result, 3. Never pass both, 4. error should be instanceof Error * Must never excecute on the same tick of the event loop * Must be passed as last argument to function * Return value is ignored * Must not throw / must pass resulting errors * Must never be called more than once Long story short, domains are broken, try/catch is insufficient, use trycatch because I solved this problem over 2 years ago and have been perfecting it since. [0] https://news.ycombinator.com/item?id=7598983 [1] http://www.meetup.com/BayNode/ [2] https://github.com/CrabDude/trycatch [3] https://github.com/CrabDude/stepup [4] https://news.ycombinator.com/item?id=7020054 [5] https://gist.github.com/CrabDude/10907185
In Comparing Node.js Promises, Try/Catch, Angular Zone.js and Zone

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.