| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 ///<reference path="../logdog-stream/logdog.ts" /> | 7 ///<reference path="../logdog-stream/logdog.ts" /> |
| 8 ///<reference path="../luci-operation/operation.ts" /> | 8 ///<reference path="../luci-operation/operation.ts" /> |
| 9 ///<reference path="../luci-sleep-promise/promise.ts" /> | 9 ///<reference path="../luci-sleep-promise/promise.ts" /> |
| 10 ///<reference path="../rpc/client.ts" /> | 10 ///<reference path="../rpc/client.ts" /> |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 new luci.Timer(Model.LOADING_WHILE_THRESHOLD_MS, () => { | 487 new luci.Timer(Model.LOADING_WHILE_THRESHOLD_MS, () => { |
| 488 if (this.loadingState === LoadingState.LOADING) { | 488 if (this.loadingState === LoadingState.LOADING) { |
| 489 this.loadingState = LoadingState.LOADING_BEEN_A_WHILE; | 489 this.loadingState = LoadingState.LOADING_BEEN_A_WHILE; |
| 490 } | 490 } |
| 491 }); | 491 }); |
| 492 | 492 |
| 493 let hasLogs = false; | 493 let hasLogs = false; |
| 494 try { | 494 try { |
| 495 hasLogs = await this.fetchLocationRound(l, op); | 495 hasLogs = await this.fetchLocationRound(l, op); |
| 496 } catch (err) { | 496 } catch (err) { |
| 497 console.log('Fetch failed with error:', err); |
| 498 |
| 497 // Cancel the timer here, since we may enter other states in this | 499 // Cancel the timer here, since we may enter other states in this |
| 498 // "catch" block and we don't want to have the timer override them. | 500 // "catch" block and we don't want to have the timer override them. |
| 499 loadingWhileTimer.cancel(); | 501 loadingWhileTimer.cancel(); |
| 500 | 502 |
| 501 // If we've been canceled, discard this result. | 503 // If we've been canceled, discard this result. |
| 502 if (err === luci.Operation.CANCELLED) { | 504 if (err === luci.Operation.CANCELLED) { |
| 503 return; | 505 return; |
| 504 } | 506 } |
| 505 | 507 |
| 506 this.clearCurrentOperation(op); | |
| 507 if (err === NOT_AUTHENTICATED) { | 508 if (err === NOT_AUTHENTICATED) { |
| 508 this.loadingState = LoadingState.NEEDS_AUTH; | 509 this.loadingState = LoadingState.NEEDS_AUTH; |
| 509 | 510 |
| 510 // We failed because we were not authenticated. Mark this | 511 // We failed because we were not authenticated. Mark this |
| 511 // so we can retry if that state changes. | 512 // so we can retry if that state changes. |
| 512 await this.authChangedPromise; | 513 await this.authChangedPromise; |
| 513 | 514 |
| 514 // Our authentication state changed during the fetch! | 515 // Our authentication state changed during the fetch! |
| 515 // Retry automatically. | 516 // Retry automatically. |
| 516 continueFetching = true; | 517 continueFetching = true; |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1445 |
| 1445 // Get the next log and increment our index. | 1446 // Get the next log and increment our index. |
| 1446 let log = this.logs[this.index++]; | 1447 let log = this.logs[this.index++]; |
| 1447 if (this.index >= this.logs.length) { | 1448 if (this.index >= this.logs.length) { |
| 1448 this.logs = null; | 1449 this.logs = null; |
| 1449 } | 1450 } |
| 1450 return log; | 1451 return log; |
| 1451 } | 1452 } |
| 1452 } | 1453 } |
| 1453 } | 1454 } |
| OLD | NEW |