Closed jahead closed 8 years ago
I fixed this by using function.bind
instead of changing the signature on executor function and added a test that verifies it's fixed.
I thought I already had test coverage for this, but my MockSocket object was using arrow functions () => {}
which always have a lexical-scoped this. Switching to normal function methods exposed the bug in the test cases as well, which made it easy to fix. Thanks for the PR and issue report!
ha a bind, I don't know why I didn't think of that. True, I was going for a quick fix for work. I'll test your fix tomorrow. But it should be fixed.
With the new update I'm getting and TypeError on the emit.
This on socket.io 1.5.0
Basically the defaultExecute function is eroding the closure on the emit. Therefore when this.sendBuffer.push is called this is actually pointing to the window in chrome, thus sendBuffer is undefined and we get glorious crashing.
I've done a simple fix, and will be in a pull request. You could also make default excute a lambda, which 'should' preserve the closure but I haven't tested this.