SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
291 stars 92 forks source link

In sctransport.js missing test if callback is defined #96

Closed elliebonne closed 6 years ago

elliebonne commented 6 years ago

Under a stress test I get:

TypeError: Cannot read property 'call' of undefined
    at Emitter.SCTransport._abortAllPendingEventsDueToBadConnection (/home/dbonne/dvp/js/webstack/miniclient/node_modules/socketcluster-client/lib/sctransport.js:189:15)
    at Emitter.SCTransport._onClose (/home/dbonne/dvp/js/webstack/miniclient/node_modules/socketcluster-client/lib/sctransport.js:205:10)
    at Timeout._onTimeout (/home/dbonne/dvp/js/webstack/miniclient/node_modules/socketcluster-client/lib/sctransport.js:269:10)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

In the code in sctransport.js I see:

  var callback = eventObject.callback;
  delete eventObject.callback;
  callback.call(eventObject, badConnectionError, eventObject);

Looks like "if(callback)" has been forgotten.

best regards

jondubois commented 6 years ago

@dirkbonne Which version of the client are you using? What are the steps to reproduce?

elliebonne commented 6 years ago

The version is 9.0.0.

I cannot easily reproduce this. I just assumed from the other parts in sctransport.js that the callback could be undefined.

best regards, Dirk

jondubois commented 6 years ago

@dirkbonne Thanks. I think was able to reproduce the same issue, it can happen when the socket disconnects soon after a specific event response callback times out on the client.

jondubois commented 6 years ago

@dirkbonne It should be fixed now in v9.0.2. Feel free to reopen this issue if not.

elliebonne commented 6 years ago

Okay thanks very much!