overleaf/overleaf · error
invalid session
Error message
invalid session
What it means
Warning logged in the socket.io connection handler when the session lookup fails with 'could not look up session by key' — the client presented an expired, revoked or unknown session key (typical after server restarts or session TTL expiry). The connection is rejected with 'invalid session' so the client re-authenticates; this is expected behavior, not a server fault.
Source
Thrown at services/real-time/app/js/Router.js:169
if (client.connected) {
client.emit('reconnectGracefully')
client.disconnect()
}
})
}
if (settings.shutDownInProgress) {
client.emit('connectionRejected', { message: 'retry' })
client.disconnect()
return
}
if (
client &&
error &&
error.message.match(/could not look up session by key/)
) {
logger.warn(
{ err: error, client: !!client, session: !!session },
'invalid session'
)
// tell the client to reauthenticate if it has an invalid session key
client.emit('connectionRejected', { message: 'invalid session' })
client.disconnect()
return
}
if (error) {
logger.err(
{ err: error, client: !!client, session: !!session },
'error when client connected'
)
if (client) {
client.emit('connectionRejected', { message: 'error' })
}
if (client) {View on GitHub (pinned to 28ad3b03b7)
Solutions
- Have the client obtain a fresh session key (re-login) and reconnect
- Verify the session store (redis) is reachable and in sync across real-time instances
- Check session TTL settings versus expected connection lifetimes
- Ignore as routine noise unless it spikes, which indicates session-store issues
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at services/real-time/app/js/Router.js:169 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03).
Data as JSON: /api/errors/090d6995484455f7.
Report an issue: GitHub.