cjohansen/Sinon.JS — Issue #47: fakeServer swallows exceptions in onreadystatechange handler
Author: runeh
Created: 2011-10-22 12:57:31+00:00
State: open

When using fakeServer, and something causes an exception in onreadystatechange, or code called from it:

Expected:

* Exceptions are logged to the console in the same way they would as if not running with fakeServer
* If an exception occurs in a onreadystatechange handler, it should not prevent onreadystatechange to be triggered for other ready states

Actual:

* Exceptions are silently caught and ignored
* Processing of request ends, without ever reaching ready state 4.

Bug occurs because of this: https://github.com/cjohansen/Sinon.JS/blob/master/lib/sinon/util/fake_server.js#L182
Example here: http://jsfiddle.net/S6VYe/3/

FWIW, there are a few other instances of "catch (e) {}" in sinon. They are almost certainly wrong as well.