You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #849 attempted to fix resaving an already-saved new session at the end of the request, but there's one corner case it missed. If session.regenerate() has been called before session.save(), then the request is still saved again at the end of the request.
This can actually lead to a race condition: if another request modifies the session after session.save() but before the end of the first request, then those modifications get overwritten when the first request ends. (And yes, this can happen in real world...)
How to reproduce: This code prints "saving" twice for one request (also verified by adding logging inside express-session)
In index.js wrapMethods, also wrap regenerate (same way as reload)
In the wrapped save method, set originalId = this.id (so that isSaved returns true and isModified false, unless more modifications happen after saving)
PR #849 attempted to fix resaving an already-saved new session at the end of the request, but there's one corner case it missed. If
session.regenerate()
has been called beforesession.save()
, then the request is still saved again at the end of the request.This can actually lead to a race condition: if another request modifies the session after
session.save()
but before the end of the first request, then those modifications get overwritten when the first request ends. (And yes, this can happen in real world...)How to reproduce: This code prints "saving" twice for one request (also verified by adding logging inside express-session)
The text was updated successfully, but these errors were encountered: