Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override connect timeout #194

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,30 @@ export class Remote {
[`${authorityParts[1]}`]: agent.operating_system,
}

// VS Code ignores the connect timeout in the SSH config and uses a default
// of 15 seconds, which can be too short in the case where we wait for
// startup scripts. For now we hardcode a longer value.
const connectTimeout = 1800

let settingsContent = "{}"
try {
settingsContent = await fs.readFile(this.storage.getUserSettingsPath(), "utf8")
} catch (ex) {
// Ignore! It's probably because the file doesn't exist.
}
const parsed = jsonc.parse(settingsContent)
parsed["remote.SSH.remotePlatform"] = remotePlatforms
const edits = jsonc.modify(settingsContent, ["remote.SSH.remotePlatform"], remotePlatforms, {})

settingsContent = jsonc.applyEdits(
settingsContent,
jsonc.modify(settingsContent, ["remote.SSH.remotePlatform"], remotePlatforms, {}),
)

settingsContent = jsonc.applyEdits(
settingsContent,
jsonc.modify(settingsContent, ["remote.SSH.connectTimeout"], connectTimeout, {}),
)

try {
await fs.writeFile(this.storage.getUserSettingsPath(), jsonc.applyEdits(settingsContent, edits))
await fs.writeFile(this.storage.getUserSettingsPath(), settingsContent)
} catch (ex) {
// The user will just be prompted instead, which is fine!
// If a user's settings.json is read-only, then we can't write to it.
Expand Down