(deployId: string)
| 659 | } |
| 660 | |
| 661 | private async pollForProcessingCompletion(deployId: string): Promise<GetDeployResponse> { |
| 662 | const {deployPollInterval: pollInterval = DEPLOY_POLL_INTERVAL_MS} = this.deployOptions; |
| 663 | |
| 664 | // Poll for processing completion |
| 665 | const spinner = this.effects.clack.spinner(); |
| 666 | spinner.start("Server processing deploy"); |
| 667 | const pollExpiration = Date.now() + DEPLOY_POLL_MAX_MS; |
| 668 | let deployInfo: null | GetDeployResponse = null; |
| 669 | pollLoop: while (true) { |
| 670 | if (Date.now() > pollExpiration) { |
| 671 | spinner.stop("Deploy timed out"); |
| 672 | throw new CliError(`Deploy failed to process on server: status = ${deployInfo?.status}`); |
| 673 | } |
| 674 | deployInfo = await this.apiClient.getDeploy(deployId); |
| 675 | switch (deployInfo.status) { |
| 676 | case "created": |
| 677 | case "pending": |
| 678 | break; |
| 679 | case "uploaded": |
| 680 | spinner.stop("Deploy complete"); |
| 681 | break pollLoop; |
| 682 | case "failed": |
| 683 | spinner.stop("Deploy failed"); |
| 684 | throw new CliError("Deploy failed to process on server"); |
| 685 | case "canceled": |
| 686 | spinner.stop("Deploy canceled"); |
| 687 | throw new CliError("Deploy canceled"); |
| 688 | default: |
| 689 | spinner.stop("Unknown status"); |
| 690 | throw new CliError(`Unknown deploy status: ${deployInfo.status}`); |
| 691 | } |
| 692 | await new Promise((resolve) => setTimeout(resolve, pollInterval)); |
| 693 | } |
| 694 | |
| 695 | if (!deployInfo) throw new CliError("Deploy failed to process on server"); |
| 696 | return deployInfo; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | // export for testing |
no test coverage detected