Fix PR not being reopened after force push with commitMode github-api#616
Draft
p-chan wants to merge 2 commits into
Draft
Fix PR not being reopened after force push with commitMode github-api#616p-chan wants to merge 2 commits into
p-chan wants to merge 2 commits into
Conversation
When using `commitMode: "github-api"`, `@changesets/ghcommit` force-pushes the branch, which causes GitHub to close any open PRs targeting that branch. The subsequent GraphQL mutation with `state: OPEN` could be a no-op if GitHub's close propagation had not completed yet, leaving the PR closed. After the mutation, verify the PR is actually open and retry reopening via REST API until confirmed, to handle cases where close propagation outlasts the GraphQL update.
🦋 Changeset detectedLatest commit: f2af10b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Andarist
reviewed
May 14, 2026
Comment on lines
+434
to
+436
| // When using commitMode: "github-api", the force push closes the PR asynchronously. | ||
| // The state: OPEN in the mutation above may be a no-op if close propagation has not | ||
| // completed yet, so verify and reopen via REST until the PR is confirmed open. |
Member
There was a problem hiding this comment.
I'm not fond of this fix. I think we should try to fix this in ghcommit: https://github.com/changesets/ghcommit/blob/1723769e9c979d2ca750c8d239414ac560c61e30/src/core.ts#L48
It seems plausible that we could use this flow to mimic the force push better:
octokit.rest.git.createTree- then
octokit.rest.git.createCommit - then
octokit.rest.git.updateRef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fixes #615
Since v1.8.0, when using
commitMode: "github-api", existing Version Packages PRs are sometimes not reopened after being closed by a force push.When using
commitMode: "github-api", the action force-pushes the branch via the GitHub API, which causes GitHub to close any open PRs targeting that branch. The subsequent GraphQL mutation withstate: OPENcould be a no-op if GitHub's close propagation had not completed yet, leaving the PR permanently closed.What
After the GraphQL update, verify the PR is actually open and retry reopening via the REST API (up to 5 times, with 3s intervals) until confirmed. This only runs when
commitMode: "github-api"is in use (git.octokit !== null).Notes