Skip to content

Intended that session is saved _after_ the response is written? #704

Description

@igrayson

Hi,

We have a simple client that sends two requests to a server using express-session:

  1. /login creates a session; store.set writes a postgres sessions row and triggers the session store callback after committed.
  2. /getSomeData requires a session to exist. The client calls this immediately after receiving the response to /login.

Our problem: the server receives /getSomeData before the postgres finishes writing to sessions.

With some breakpoints and tcpdump, I discovered that express-session intercepts request.end(), to call store.set before request.end is called. However, tcpdump demonstrates the response may already be completed -- written to the wire -- by this point (e.g., request.write() has already been called).

Question: is it intended that the session is saved after the response is written to the wire?

If so, is there a concern that this allows a race condition where follow-up requests may present a cookie for a session that has not yet been saved?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions