[1] I'm a little bit worried about a scoping problem with 'exit_with_error' being assigned a value *after* the 'got_error' function is defined. It might be just because scoping is trickier in Javascript. I would just move the assignment before the function or pass the variable as an argument to the function instead.
[2] The setup() function has a similar code path. I suspect it can stay as it is because it's not used as a callback? Just for clarification.
[1] I'm a little bit worried about a scoping problem with 'exit_with_error' being assigned a value *after* the 'got_error' function is defined. It might be just because scoping is trickier in Javascript. I would just move the assignment before the function or pass the variable as an argument to the function instead.
[2] The setup() function has a similar code path. I suspect it can stay as it is because it's not used as a callback? Just for clarification.
Other than that, looks good. +1.