Fix remoteAddress workaround
Tree shaking removed the remoteAddress workaround because property access should have no side effect. This change prevents that.
This commit is contained in:
1 parent
559aa0fd36
commit
209c0f7620
1 file changed
+6
-2
+6
-2
@@ -824,11 +824,15 @@ async function getSession(connection, sessionId): Promise<SessionContext> {
|
||||
return session.deserialize(sessionContextString);
|
||||
}
|
||||
|
||||
// Only needed to prevent tree shaking from removing the remoteAddress
|
||||
// workaround in onConnection function.
|
||||
const remoteAddressWorkaround = new WeakMap<Socket, string>();
|
||||
|
||||
// When socket closes, store active sessions in cache
|
||||
export function onConnection(socket): void {
|
||||
export function onConnection(socket: Socket): void {
|
||||
// The property remoteAddress may be undefined after the connection is
|
||||
// closed, unless we read it at least once (caching?)
|
||||
socket.remoteAddress;
|
||||
remoteAddressWorkaround.set(socket, socket.remoteAddress);
|
||||
|
||||
socket.on("close", async () => {
|
||||
const sessionContext = currentSessions.get(socket);
|
||||
|
||||
Reference in new issue
Block a user