Calling connection.stop() with the serverSentEvent transport on Opera raises a TypeError. #1519

Closed
halter73 opened this Issue Feb 12, 2013 · 1 comment

Comments

Projects
None yet
2 participants
Member

halter73 commented Feb 12, 2013

REPRO

  • Start SignalR connection with the serverSentEvents transport on Opera.
  • Call connection.stop() after the the connection has reached the connected state.
  • An Uncaught exception: TypeError: Cannot convert 'connection.eventSource' to object will be thrown

Alternatively, you can run the "Connection State Facts: serverSentEvents Manually restarted client maintains consistent state" functional test in the JS test project on Opera.

CAUSE

Opera raises error after EventSource.Close is called which is handled by our function wired via connection.eventSource.addEventListener("error", ....

Since signalR.transports.serverSentEvents.stop(connection) is called before the error handler is called: connection.eventSource is null by the time the error handler is fired. Therefore, trying to access connection.eventSource.readyState in the error event handler fails.

FIX

While using this instead of connection.eventSource inside the error handler would fix the AV, there is no reason for the error handler to do anything if the transport that created it was stopped.

I think it is better to set connection.eventSource.ID to null in signalR.transports.serverSentEvents.stop so the error handler will ignore the event since it won't match the currentEventSourceID.

@ghost ghost assigned halter73 Feb 12, 2013

halter73 added a commit that referenced this issue Feb 12, 2013

halter73 added a commit that referenced this issue Feb 12, 2013

Contributor

Xiaohongt commented Feb 13, 2013

verified

@Xiaohongt Xiaohongt closed this Feb 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment