@@ -273,17 +273,35 @@ export class Remote {
273273 [ `${ authorityParts [ 1 ] } ` ] : agent . operating_system ,
274274 }
275275
276+ // VS Code ignores the connect timeout in the SSH config and uses a default
277+ // of 15 seconds, which can be too short in the case where we wait for
278+ // startup 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