Skip to content

Commit

Permalink
Merge pull request #2790 from murgatroid99/grpc-js_server_idle_test_d…
Browse files Browse the repository at this point in the history
…eflake

grpc-js: Increase state change deadline in server idle tests
  • Loading branch information
murgatroid99 committed Jul 10, 2024
2 parents c934257 + 395de4b commit fbbc78d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 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
6 changes: 3 additions & 3 deletions packages/grpc-js/test/test-idle-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('Server idle timer', () => {
grpc.connectivityState.READY
);
client?.waitForClientState(
Date.now() + 600,
Date.now() + 1500,
grpc.connectivityState.IDLE,
done
);
Expand All @@ -217,7 +217,7 @@ describe('Server idle timer', () => {
);

client!.waitForClientState(
Date.now() + 600,
Date.now() + 1500,
grpc.connectivityState.IDLE,
err => {
if (err) return done(err);
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('Server idle timer', () => {
);

client!.waitForClientState(
Date.now() + 600,
Date.now() + 1500,
grpc.connectivityState.IDLE,
done
);
Expand Down

0 comments on commit fbbc78d

Please sign in to comment.