Add timeout when flashing from the app takes too long (#1070)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							f0d14c918e
						
					
				
				
					commit
					7537c7561f
				
			@@ -652,7 +652,28 @@ namespace pxt.editor {
 | 
				
			|||||||
        }])
 | 
					        }])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (canHID())
 | 
					        if (canHID())
 | 
				
			||||||
            pxt.commands.deployCoreAsync = deployCoreAsync;
 | 
					            pxt.commands.deployCoreAsync = (r: pxtc.CompileResult, d: pxt.commands.DeployOptions): Promise<void> => {
 | 
				
			||||||
 | 
					                return deployCoreAsync(r)
 | 
				
			||||||
 | 
					                    .timeout(18000)
 | 
				
			||||||
 | 
					                    .catch((e) => {
 | 
				
			||||||
 | 
					                        return previousDapWrapper.reconnectAsync(true)
 | 
				
			||||||
 | 
					                            .catch((e) => {
 | 
				
			||||||
 | 
					                                // Best effort disconnect; at this point we don't even know the state of the device
 | 
				
			||||||
 | 
					                                pxt.reportException(e);
 | 
				
			||||||
 | 
					                            })
 | 
				
			||||||
 | 
					                            .then(() => {
 | 
				
			||||||
 | 
					                                return r.confirmAsync({
 | 
				
			||||||
 | 
					                                    header: lf("Something went wrong..."),
 | 
				
			||||||
 | 
					                                    body: lf("Flashing your {0} took too long. Please disconnect your {0} from your computer and try reconnecting it.", pxt.appTarget.appTheme.boardName || lf("device")),
 | 
				
			||||||
 | 
					                                    disagreeLbl: lf("Ok"),
 | 
				
			||||||
 | 
					                                    hideAgree: true
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            })
 | 
				
			||||||
 | 
					                            .then(() => {
 | 
				
			||||||
 | 
					                                return pxt.commands.saveOnlyAsync(r);
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        res.blocklyPatch = patchBlocks;
 | 
					        res.blocklyPatch = patchBlocks;
 | 
				
			||||||
        return Promise.resolve<pxt.editor.ExtensionResult>(res);
 | 
					        return Promise.resolve<pxt.editor.ExtensionResult>(res);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user