deepstreamIO / deepstream.io-provider-search-rethinkdb

A data-provider that makes every table searchable via rethinkdb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscribing and then deleting crashes server

Iiridayn opened this issue · comments

Subscribing to a search, then deleting it when done crashes the server. This is the best practice suggested at https://deepstream.io/tutorials/core/searching-and-querying/.

var users = client.record.getList('search?' + JSON.stringify({ table: 'users', query: [] })); users.on('error', e => console.log("fail", e)); users.whenReady((foo) => console.log(foo.getEntries()));
users.delete(); // after `whenReady` has returned

Note that I'm running the search provider and the deepstream.io server both from the same process, using the nodejs api for the latter.
Log output:

      _                     _                              _
   __| | ___  ___ _ __  ___| |_ _ __ ___  __ _ _ __ ___   (_) ___
  / _` |/ _ \/ _ \ '_ \/ __| __| '__/ _ \/ _` | '_ ` _ \  | |/ _ \
 | (_| |  __/  __/ |_) \__ \ |_| | |  __/ (_| | | | | | |_| | (_) |
  \__,_|\___|\___| .__/|___/\__|_|  \___|\__,_|_| |_| |_(_)_|\___/
                 |_|
 =========================   starting   ==========================
2:36:36 PM:168 | Initialising RethinkDb Connection
2:36:36 PM:178 | RethinkDb connection established
2:36:36 PM:178 | Initialising Deepstream connection
2:36:36 PM:185 | Connection to deepstream established
2:36:36 PM:186 | listening for search[\?].*
2:36:36 PM:187 | rethinkdb search provider ready
2:36:53 PM:553 | received subscription for search?{"table":"sub","query":[["random","gt",0.5]]}
undefined
2:36:59 PM:555 | received subscription for search?{"table":"users","query":[]}
2:37:03 PM:681 | Removing search search?{"table":"users","query":[]}
2:37:03 PM:684 | discard subscription for search?{"table":"users","query":[]}
/var/www/vhosts/modules.payzoom.com/node_modules/deepstream.io-provider-search-rethinkdb/src/search.js:54
  this._provider.log( 'Removing search ' + this._list.name )
                                                     ^

TypeError: Cannot read property 'name' of null
    at Search.destroy (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/src/search.js:54:54)
    at Provider._onSubscription (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/src/provider.js:220:28)
    at Listener._$onMessage (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/node_modules/deepstream.io-client-js/src/utils/listener.js:30:14)
    at RecordHandler._$handle (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/node_modules/deepstream.io-client-js/src/record/record-handler.js:243:26)
    at Client._$onMessage (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/node_modules/deepstream.io-client-js/src/client.js:128:42)
    at Connection._onMessage (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/node_modules/deepstream.io-client-js/src/message/connection.js:322:17)
    at emitOne (events.js:96:13)
    at emit (events.js:188:7)
    at TcpConnection._onData (/var/www/test.example.com/node_modules/deepstream.io-provider-search-rethinkdb/node_modules/deepstream.io-client-js/src/tcp/tcp-connection.js:180:7)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)

⁠⁠⁠⁠Search._destroy⁠⁠⁠⁠ is getting called twice - once when the ⁠⁠⁠⁠List⁠⁠⁠⁠ is deleted, the second time when that deletion triggers the unsubscribe - the second time through though, _list is null, so ⁠_⁠⁠⁠list.name⁠⁠⁠⁠ is undefined... Removing the ⁠⁠⁠⁠on('delete', _destroy)⁠⁠⁠⁠ fixes that. Still not certain about side effects.

Probably fixed in the process of updating to 1.1; clients shouldn't delete records anymore as in #24.

Yup, this should now be resolved. Closing