Hi,
We have a simple client that sends two requests to a server using express-session:
/login creates a session; store.set writes a postgres sessions row and triggers the session store callback after committed.
/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?
Hi,
We have a simple client that sends two requests to a server using
express-session:/logincreates a session;store.setwrites a postgressessionsrow and triggers the session store callback after committed./getSomeDatarequires a session to exist. The client calls this immediately after receiving the response to/login.Our problem: the server receives
/getSomeDatabefore the postgres finishes writing tosessions.With some breakpoints and
tcpdump, I discovered that express-session interceptsrequest.end(), to callstore.setbeforerequest.endis called. However,tcpdumpdemonstrates 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?