Skip to content

Commit ef5bf5b

Browse files
committed
Override connect timeout
1 parent d775e37 commit ef5bf5b

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/remote.ts

+21-3
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,35 @@ export class Remote {
273273
[`${authorityParts[1]}`]: agent.operating_system,
274274
}
275275

276+
// VS Code ignores the timeout in the SSH config with a default of 15
277+
// seconds, which can be too short in the case where we wait for startup
278+
// scripts. For now we hardcode a longer value.
279+
const connectTimeout = 1800
280+
276281
let settingsContent = "{}"
277282
try {
278283
settingsContent = await fs.readFile(this.storage.getUserSettingsPath(), "utf8")
279284
} catch (ex) {
280285
// Ignore! It's probably because the file doesn't exist.
281286
}
282-
const parsed = jsonc.parse(settingsContent)
287+
288+
// The parser can return undefined if the file is blank.
289+
const parsed = jsonc.parse(settingsContent) || {}
283290
parsed["remote.SSH.remotePlatform"] = remotePlatforms
284-
const edits = jsonc.modify(settingsContent, ["remote.SSH.remotePlatform"], remotePlatforms, {})
291+
parsed["remote.SSH.connectTimeout"] = connectTimeout
292+
293+
settingsContent = jsonc.applyEdits(
294+
settingsContent,
295+
jsonc.modify(settingsContent, ["remote.SSH.remotePlatform"], remotePlatforms, {}),
296+
)
297+
298+
settingsContent = jsonc.applyEdits(
299+
settingsContent,
300+
jsonc.modify(settingsContent, ["remote.SSH.connectTimeout"], connectTimeout, {}),
301+
)
302+
285303
try {
286-
await fs.writeFile(this.storage.getUserSettingsPath(), jsonc.applyEdits(settingsContent, edits))
304+
await fs.writeFile(this.storage.getUserSettingsPath(), settingsContent)
287305
} catch (ex) {
288306
// The user will just be prompted instead, which is fine!
289307
// If a user's settings.json is read-only, then we can't write to it.

0 commit comments

Comments
 (0)