balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

`requestQueues` not able to queue more than one request #6534

Closed MaxDesiatov closed 5 years ago

MaxDesiatov commented 10 years ago

steps to reproduce:

 io.socket.get('/blah', function () {
     console.log('blah');
 });
requestQueues[self.id] = requestQueues[self.id] || [];
requestQueues[self.id].push(request);
mikermcneil commented 10 years ago

@explicitcall thanks, Ill take a look!

mikermcneil commented 10 years ago

@explicitcall ok, so first of all, thanks for bringing this to my attention. I did some work here that gets us part of the way there, but there's still some things left to be done to make the request queueing work for multiple sockets. Currently, it's not a use case my team has on our plate so I can't really justify any more time working to make it possible, but I'm more than happy to accept a PR from anyone who needs this feature and has a few minutes to finish the job.

Basically e94e228e68925c4cbd48c5fe5e07de3631b63fb8 sets things up so that each socket instance has a requestQueue. The requestQueue is being run when TmpSocket.prototype.become() gets called. The issue is that TmpSocket is only being instantiated for the initial io.socket and not all other sockets. Basically we just need to return a new TmpSocket instance from our io.connect override, start connecting a real socket (which we already do), then when that realSocket finishes connecting, we need to call fakeSocket.become(realSocket). As I mentioned, this code already exists in the SDK, but as a one-off for io.socket-- the next step is to make it generic.

Thanks again!

mikermcneil commented 10 years ago

Made an issue for the multi-socket use case here so we can go ahead and close this one

mikermcneil commented 10 years ago

@explicitcall just released sails.io.js@v0.10.0-rc4 to npm and bower with this fix (and a few other improvements)

Link: https://github.com/balderdashy/sails.io.js/releases/tag/v0.10.0-rc4

MaxDesiatov commented 10 years ago

thank you! will give it a try