Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token 1 not in stream cache. #270

Closed
chrisabrams opened this issue Aug 2, 2016 · 11 comments
Closed

Token 1 not in stream cache. #270

chrisabrams opened this issue Aug 2, 2016 · 11 comments

Comments

@chrisabrams
Copy link

I'm not sure if this is actually an error, as my code runs as intended. I came across this while working with change feeds.

ReqlClientError: Token 1 not in stream cache.
    at Connection._processResponse (node_modules/rethinkdbdash/lib/connection.js:362:21)
    at Socket.<anonymous> (node_modules/rethinkdbdash/lib/connection.js:201:14)
    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)

I only saw it because during debugging I have the process.uncaughtException fire a console.error.

@neumino
Copy link
Owner

neumino commented Aug 3, 2016

Hum how often does this happen?

@chrisabrams
Copy link
Author

I will send you a test tomorrow I wrote that can repeat this each time it's run.

@neumino
Copy link
Owner

neumino commented Aug 7, 2016

@chrisabrams -- can you send me a script to reproduce this error when you have some time? Thanks!

This error can happen if we request more data for a cursor that's empty, but this shouldn't happen with rethinkdbdash as we parse the response before requesting more data.

@chrisabrams
Copy link
Author

Before I do that, I first need help with this: #272

@chrisabrams
Copy link
Author

chrisabrams commented Aug 13, 2016

Alright, here is how to reproduce this error on this project: https://github.com/f12/structure-api

  • clone the project
  • npm install
  • start a rethinkdb instance on default port 28015. This will use the db test. reqlite will not work for this test since it doesn't support the type of push im trying to do with rethinkdb. See: <non-index>,changes() is currently not supported reqlite#33
  • run the command: npm run test-integration

You will see the error pop up on the 2nd of 2 tests:

Unhandled Rejection
Token 1 not in stream cache.
ReqlClientError: Token 1 not in stream cache.

The cursor is emitting the changes from the root model of the project.

@neumino
Copy link
Owner

neumino commented Aug 13, 2016

Hum, that's a gigantic repo and I have a hard time browsing through that.
Can you provide a single file that trigger this issue?

@chrisabrams
Copy link
Author

chrisabrams commented Aug 13, 2016

The root model that I linked to at the bottom of the last comment is the only line of code in the repo that uses the change feed / cursor. In that file:

@neumino
Copy link
Owner

neumino commented Aug 15, 2016

Fixed in 2.3.21.
@chrisabrams - FYI, you are closing multiple times the same feed, so I guess you are not properly deleting references of feeds in your code.

@chrisabrams
Copy link
Author

Hmmm. Alright, I'll have to dig deeper on that :O

At least my bug helped fix something :)

@chrisabrams
Copy link
Author

@neumino yes, in this test, I am closing the cursors twice. There are two places that keep track of the cursors: the model and the server. If the server shuts down or restarts, I want to tell the cursors to close, and if the model is disposed, then I tell the cursors for that model to close.

Therefore, I have a full list of cursors, as well as a list per model. Ideally, when a model is disposed of, I could remove the cursor by ID from the full list.

Is that what the token is? An incremental count up of the change feeds?

@neumino
Copy link
Owner

neumino commented Aug 15, 2016

No, the token is a RethinkDB concept - https://www.rethinkdb.com/docs/writing-drivers/
It's roughtly a query ID and is used mostly to request more data when RethinkDB return a cursor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants