From 77ba820f08188f62578b2ed4bc435d46ba5ddf55 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Wed, 1 Apr 2020 17:25:06 -0700 Subject: [PATCH] fix: delay snapshots temporarily (#391) --- src/release-pr.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/release-pr.ts b/src/release-pr.ts index a8f6d49b3..d57671378 100644 --- a/src/release-pr.ts +++ b/src/release-pr.ts @@ -103,7 +103,26 @@ export class ReleasePR { this.gh = this.gitHubInstance(options.octokitAPIs); } + async delay({ms = 3000}) { + new Promise((resolve, reject) => { + setTimeout(() => { + return resolve(); + }, ms); + }); + } + async run() { + // TODO: this temporarily resolves a race condition between creating a release + // and updating tags on the release PR. This should be replaced by a queuing + // mechanism to delay/retry this request. + if (this.snapshot) { + checkpoint( + 'snapshot: sleeping for 10 seconds...', + CheckpointType.Success + ); + await this.delay({ms: 10000}); + checkpoint('snapshot: finished sleeping', CheckpointType.Success); + } const pr: GitHubReleasePR | undefined = await this.gh.findMergedReleasePR( this.labels );