cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

Auto-renewed session cookies do not persist beyond original session lifetime #463

Closed ricellis closed 3 years ago

ricellis commented 3 years ago

Bug Description

Auto-renewed session cookies do not persist beyond original session lifetime.

It turns out request uses tough-cookie and this problem is caused by https://github.com/salesforce/tough-cookie/issues/154 and is very similar to https://github.com/IBM/cloudant-node-sdk/issues/209. The reason it was not obvious before in this library was that a 401 response causes a fallback renewal so it was typically masked by that fallback renewal attempt.

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

  1. Make a request that starts a session
  2. Wait until an auto-renew happens at 50% of the session lifetime, getting a second session
  3. Make a second request as the first session lifetime finishes

2. What you expected to happen

The second request should have the cookie for the second session.

3. What actually happened

The second request has no cookie (as is purged at the first session expiry time).

Environment details