@@ -273,17 +273,35 @@ export class Remote {
273
273
[ `${ authorityParts [ 1 ] } ` ] : agent . operating_system ,
274
274
}
275
275
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
+
276
281
let settingsContent = "{}"
277
282
try {
278
283
settingsContent = await fs . readFile ( this . storage . getUserSettingsPath ( ) , "utf8" )
279
284
} catch ( ex ) {
280
285
// Ignore! It's probably because the file doesn't exist.
281
286
}
282
- const parsed = jsonc . parse ( settingsContent )
287
+
288
+ // The parser can return undefined if the file is blank.
289
+ const parsed = jsonc . parse ( settingsContent ) || { }
283
290
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
+
285
303
try {
286
- await fs . writeFile ( this . storage . getUserSettingsPath ( ) , jsonc . applyEdits ( settingsContent , edits ) )
304
+ await fs . writeFile ( this . storage . getUserSettingsPath ( ) , settingsContent )
287
305
} catch ( ex ) {
288
306
// The user will just be prompted instead, which is fine!
289
307
// If a user's settings.json is read-only, then we can't write to it.
0 commit comments