Skip to content

Commit

Permalink
grpc-js: Refresh server idle timer if not enough time has passed
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Jul 9, 2024
1 parent 745a451 commit 395de4b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1790,19 +1790,22 @@ export class Server {
// for future refreshes
if (
sessionInfo !== undefined &&
sessionInfo.activeStreams === 0 &&
Date.now() - sessionInfo.lastIdle >= ctx.sessionIdleTimeout
sessionInfo.activeStreams === 0
) {
ctx.trace(
'Session idle timeout triggered for ' +
socket?.remoteAddress +
':' +
socket?.remotePort +
' last idle at ' +
sessionInfo.lastIdle
);
if (Date.now() - sessionInfo.lastIdle >= ctx.sessionIdleTimeout) {
ctx.trace(
'Session idle timeout triggered for ' +
socket?.remoteAddress +
':' +
socket?.remotePort +
' last idle at ' +
sessionInfo.lastIdle
);

ctx.closeSession(session);
ctx.closeSession(session);
} else {
sessionInfo.timeout.refresh();
}
}
}

Expand Down

0 comments on commit 395de4b

Please sign in to comment.