Sails v0.10.x not sending update or addedTo messages when in Production Mode

172 Views Asked by At

I'm running into an issue with Sails WebSockets in production mode. When I run Sails in development mode - i.e. sails lift - I receive all messages on the firehose. However, when I run Sails in production mode - i.e. sails lift --prod - I only receive create messages.

For example, my socket listener code looks like:

io.socket.get('/firehose', function nowListeningToFirehose(message) {

    // Attach a listener which fires every time the server publishes
    // a message to the firehose, then dispatch messages to simple handlers
    io.socket.on('firehose', function newMessageFromSails(message) {
        console.log('Firehose message: ', message);

        switch (message.model) {

            // Handle messages related to Rooms
            case 'room':
                processRoomMessage(message);
                break;

            // Handle messages related to Person(s)
            case 'person':
                processPersonMessage(message);
                break;

            default:
                break;

        }
    });

When I run in development mode, I get update and addedTo messages for room. I also get create and update messages for person. However, when I run in production mode. I only get create messages for user, no update or addedTo messages.

I am running Sails v.0.10.2.

2

There are 2 best solutions below

0
On BEST ANSWER

OK. Per the following log message from Sails, the firehose is turned off in production mode.

Warning: A client socket was just subscribed to the firehose, but the environment is set to `production`. Firehose messages are only delivered in the development environment.

It doesn't explain why I'm getting create messages, but does at least explain why I don't get update or addedTo messages.

0
On

Looks like there's a bug in the Sails pubsub implementation that causes firehose messages to be send out on publishCreate calls. It's being patched now. As you saw in the warning (and as is stated in the documentation the firehose is strictly intended as a development tool. Thanks for the report!