Skip to content

Race condition when saving session and redirecting #121

@KidkArolis

Description

@KidkArolis

I'm running into an issue, which I think matches exactly what's being discussed here: expressjs/session#309.

REQ #1 > start processing /oauth/google/callback
REQ #1 > set user data to session
REQ #1 > issue redirect to /oauth/google/authenticated callback
REQ #1 > express-session intercepts redirect to wait for session to persist

browser already received redirect headers and issues the new request

REQ #2 > start processing /oauth/google/authenticated
REQ #2 > get user data from session, but nothing is found
REQ #2 > completed processing /oauth/google/authenticated with error

the other request is still being processed

REQ #1 > session persist completed
REQ #1 > express-session completes the redirect, i.e. closes the connection
REQ #1 > completed processing /oauth/google/callback

I'm not 100% sure this is exactly what's happening, but it looks like it. I will try to wrap grant's redirect in req.session.save(() => { res.redirect() }) to see if that helps, since I am generally able to reproduce this fairly easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions