losandes / socket.io-mongodb

A MongoDB Adapter for socket.io
MIT License
25 stars 8 forks source link

Seems to fail with Mongo 3.4.3 #7

Open jeremieca opened 7 years ago

jeremieca commented 7 years ago

Hello,

I move to Mongo 3.4.3 (previously 2.x). Since migration, my project has a bug and after some investigations, I strongly suspect Socket.io-mongodb.

When I launch the project I have the following error :

Development/core.node/node_modules/mongodb/lib/utils.js:98
    process.nextTick(function() { throw err; });
                                  ^
MongoError: The field 'strict' is not a valid collection option. Options: { capped: true, autoIndexId: true, size: 5242880, strict: false }
    at Function.MongoError.create (Development/core.node/node_modules/mongodb-core/lib/error.js:31:11)
    at Development/core.node/node_modules/mongodb-core/lib/topologies/server.js:778:66
    at Callbacks.emit (Development/core.node/node_modules/mongodb-core/lib/topologies/server.js:95:3)
    at Connection.messageHandler (Development/core.node/node_modules/mongodb-core/lib/topologies/server.js:249:23)
    at Socket.<anonymous> (Development/core.node/node_modules/mongodb-core/lib/connection/connection.js:266:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:548:20)

And when I launch mongodb-core in debug mode, I see that :

[DEBUG-Db:20429] 1491242096446 executing command {"create":"pubsub","capped":true,"autoIndexId":true,"size":5242880,"strict":false} against ws-dev.$cmd with options [{"readPreference":{"mode":"primary"}}] { type: 'debug',
  message: 'executing command {"create":"pubsub","capped":true,"autoIndexId":true,"size":5242880,"strict":false} against ws-dev.$cmd with options [{"readPreference":{"mode":"primary"}}]',
  className: 'Db',
  pid: 20429,
  date: 1491242096446 }
[DEBUG-Server:20429] 1491242096446 executing command [{"ns":"ws-dev.$cmd","cmd":{"create":"pubsub","capped":true,"autoIndexId":true,"size":5242880,"strict":false},"options":{"size":5242880}}] against localhost:27017 { type: 'debug',
  message: 'executing command [{"ns":"ws-dev.$cmd","cmd":{"create":"pubsub","capped":true,"autoIndexId":true,"size":5242880,"strict":false},"options":{"size":5242880}}] against localhost:27017',
  className: 'Server',
  pid: 20429,
  date: 1491242096446 }

We see the strict: false, responsible of the error. It applies on wsdev database, given in my socket.io-mongo connection Uri. And it tries to create pubsub collection coming from socket.io-mongo. Creation failed.

Maybe it seems like the last version of Mongo requires some dependencies update in socket.io-mongo ?

jeremieca commented 7 years ago

Ok, after more research, the problem comes from MubSub library.

Remove this line solve the problem :

https://github.com/scttnlsn/mubsub/blob/master/lib/channel.js#L24

jeremieca commented 7 years ago

I opened an issue in Mubsub : https://github.com/scttnlsn/mubsub/issues/60