Merge pull request #185258 from microsoft/tyriar/130320

Wait 20 seconds for first pty host heartbeat
This commit is contained in:
Daniel Imms
2023-06-15 11:21:13 -07:00
committed by GitHub
2 changed files with 9 additions and 4 deletions
@@ -392,6 +392,12 @@ export enum HeartbeatConstants {
* The duration between heartbeats
*/
BeatInterval = 5000,
/**
* The duration of the first heartbeat while the pty host is starting up. This is much larger
* than the regular BeatInterval to accomodate slow machines, we still want to warn about the
* pty host's unresponsiveness eventually though.
*/
ConnectingBeatInterval = 20000,
/**
* Defines a multiplier for BeatInterval for how long to wait before starting the second wait
* timer.
@@ -149,8 +149,7 @@ export class PtyHostService extends Disposable implements IPtyService {
// Setup heartbeat service and trigger a heartbeat immediately to reset the timeouts
const heartbeatService = ProxyChannel.toService<IHeartbeatService>(client.getChannel(TerminalIpcChannels.Heartbeat));
heartbeatService.onBeat(() => this._handleHeartbeat());
// TODO: Starting the heartbeat tracking now causes problems
this._handleHeartbeat();
this._handleHeartbeat(true);
// Handle exit
this._register(connection.onDidProcessExit(e => {
@@ -351,9 +350,9 @@ export class PtyHostService extends Disposable implements IPtyService {
this._connection.store.dispose();
}
private _handleHeartbeat() {
private _handleHeartbeat(isConnecting?: boolean) {
this._clearHeartbeatTimeouts();
this._heartbeatFirstTimeout = setTimeout(() => this._handleHeartbeatFirstTimeout(), HeartbeatConstants.BeatInterval * HeartbeatConstants.FirstWaitMultiplier);
this._heartbeatFirstTimeout = setTimeout(() => this._handleHeartbeatFirstTimeout(), isConnecting ? HeartbeatConstants.ConnectingBeatInterval : (HeartbeatConstants.BeatInterval * HeartbeatConstants.FirstWaitMultiplier));
if (!this._isResponsive) {
this._isResponsive = true;
this._onPtyHostResponsive.fire();