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

Removing expired sessions after migrating to V4. #388

Closed
goto1 opened this issue Feb 22, 2021 · 6 comments
Closed

Removing expired sessions after migrating to V4. #388

goto1 opened this issue Feb 22, 2021 · 6 comments
Assignees
Milestone

Comments

@goto1
Copy link

goto1 commented Feb 22, 2021

  • I'm submitting a ...
    [x] question about how to use this project

  • Summary

Hello, thank you for this great package.

I have a question related to changes in V4 for the autoRemove and autoRemoveInterval feature.

In V3 I was able to use autoRemove: interval & autoRemoveInterval: 20, which sounds like a different behavior than what I would get with autoRemove: native that creates a TTL index at startup using MongoDB's TTL collection feature.

In V4, it looks like I can disable the MongoDB's TTL collection feature by setting createAutoRemoveIdx: false, but it doesn't look like it's going to remove expired sessions similarly to what was available in V3 - does this mean that expired sessions will have to be removed manually now?

The issue I am running into is that I am using Azure Cosmos DB, which works a little differently than a "native" MongoDB instance so I am unable to use the TTL collection feature.

Any tips or clarifications would be greatly appreciated.

Thanks!

@goto1 goto1 changed the title Removing expired sessions after migrating to V4. Removing expired sessions after migrating to V4. Feb 22, 2021
@mingchuno
Copy link
Collaborator

You are correct. I have removed the autoRemove & autoRemoveInterval and rely only on TTL collection feature. If you have a legit use case. I think I can add back the options

@mingchuno mingchuno added the bug label Feb 23, 2021
@mingchuno mingchuno added this to the 4.2 milestone Feb 23, 2021
@goto1
Copy link
Author

goto1 commented Feb 23, 2021

@mingchuno thank you for your response.

I wanted to confirm that's still the case, and it appears to be, but the problem I am running into is because I am using MongoDB with Azure Cosmos DB and according to the docs,

_ts is a Cosmos DB-specific field and is not accessible from MongoDB clients. It is a reserved (system) property that contains the timestamp of the document's last modification.

I used autoRemove: "interval" and autoRemoveInterval: 10 in V3 based on the suggestion I found on StackOverflow as a workaround.

In case if needed, following migration steps for V4, when I remove autoRemove & autoRemoveInterval and rely on the createAutoRemoveIdx option, I get an error message related to the issue described above:

(node:7826) UnhandledPromiseRejectionWarning: MongoError: The 'expireAfterSeconds' option is supported on '_ts' field only.
    at MessageStream.messageHandler (/home/xx1234/Development/my-project/node_modules/mongodb/lib/cmap/connection.js:268:20)
    at MessageStream.emit (events.js:315:20)
    at processIncomingData (/home/xx1234/Development/my-project/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
    at MessageStream._write (/home/xx1234/Development/my-project/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at MessageStream.Writable.write (internal/streams/writable.js:303:10)
    at TLSSocket.ondata (internal/streams/readable.js:719:22)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
    at TLSWrap.callbackTrampoline (internal/async_hooks.js:131:14)

Thanks for all the help so far!

@mingchuno mingchuno self-assigned this Feb 24, 2021
@mingchuno
Copy link
Collaborator

@goto1 released in 4.2.0. Please check
8c1d180

@goto1
Copy link
Author

goto1 commented Feb 24, 2021

@mingchuno works beautifully, thank you!

Would you take a PR that updates the more options section and puts back the autoRemove & autoRemoveInterval options?

Thanks again!

@mingchuno
Copy link
Collaborator

@goto1 Ya I missed that. Let me add it back

@goto1
Copy link
Author

goto1 commented Feb 24, 2021

@mingchuno thank you for your prompt responses, much appreciated!

Have a good rest of the week.

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

No branches or pull requests

2 participants