Skip to content

add inactivity timeout on client disconnect#3

Merged
seanmcguire12 merged 3 commits into
mainfrom
add-close-on-disconnect
May 20, 2026
Merged

add inactivity timeout on client disconnect#3
seanmcguire12 merged 3 commits into
mainfrom
add-close-on-disconnect

Conversation

@seanmcguire12
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@pirate pirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs 1:1 updates in all the other languages

this._stopHeartbeat();
if (this.server?.server_close_browser_on_downstream_disconnect !== true) return;
const interval_ms = this.client.client_heartbeat_interval_ms;
this.heartbeat_timer = setInterval(() => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's jitter or a lag spike this will stack a bunch of pings and make it worse, we may want to debounce this eventually but it's ok for now.

Comment thread js/src/client/ModCDPClient.ts Outdated
const interval_ms = this.client.client_heartbeat_interval_ms;
this.heartbeat_timer = setInterval(() => {
if (this.ext_session_id) {
void this._sendRaw(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use the untyped api?

Suggested change
void this._sendRaw(
void this.Mod.ping(

Comment thread js/src/server/ModCDPServer.ts Outdated
Comment on lines +104 to +106
function downstreamClientKey(_cdpSessionId: string | null) {
return DOWNSTREAM_CLIENT_KEY;
}
Copy link
Copy Markdown
Member

@pirate pirate May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function downstreamClientKey(_cdpSessionId: string | null) {
return DOWNSTREAM_CLIENT_KEY;
}

Unnecessary getter, just use DOWNSTREAM_CLIENT_KEY, but also why is DOWNSTREAM_CLIENT_KEY as a constant needed at all? shouldnt we just use a uuid or session id per client or something?

Copy link
Copy Markdown
Member

@pirate pirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved for now assuming you tested it in all langs and it works, but see my comments for follow-up improvements

@seanmcguire12 seanmcguire12 merged commit 4856a7d into main May 20, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants