Skip to content

Fix PR not being reopened after force push with commitMode github-api#616

Draft
p-chan wants to merge 2 commits into
changesets:mainfrom
p-chan:fix-reopen-after-force-push
Draft

Fix PR not being reopened after force push with commitMode github-api#616
p-chan wants to merge 2 commits into
changesets:mainfrom
p-chan:fix-reopen-after-force-push

Conversation

@p-chan
Copy link
Copy Markdown

@p-chan p-chan commented May 14, 2026

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 with state: OPEN could 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

  • Tested against a production repository that was consistently hitting this issue

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-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

🦋 Changeset detected

Latest commit: f2af10b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/action Patch

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

Comment thread src/run.ts
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Andarist Andarist requested a review from s0 May 14, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version Packages PR not reopened after force push when using commitMode: "github-api" (regression since v1.8.0)

2 participants