tgymnich / fork-sync

πŸ”„ Github action to sync your forks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ocassional Non PRs Being Merged

Mythra opened this issue Β· comments

First off thanks much for this project, it's a big help! Occasionally PRs aren't getting automatically merged, when synchronizing a fork. This isn't too destructive since I can hit merge, but is a pain to go back and forth πŸ˜… .

[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
(node:2543) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
    at /home/runner/work/_actions/TG908/fork-sync/v1.1/lib/main.js:40:82
    at Generator.throw (<anonymous>)
    at rejected (/home/runner/work/_actions/TG908/fork-sync/v1.1/lib/main.js:6:65)
(node:2543) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:2543) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

These seem to be the logs, I'm guessing there's a ratelimit or something similar, but unclear how to debug further. Any ideas would be helpful!

I am aware of this issue. But I don't know why it occurs. We are even using the octokit retry plugin to retry failed requests. At least the error message should be improved to dig deeper in the future πŸ˜„

I went ahead and updated all the dependencies for v1.2 maybe this will help it.

Looks like v1.2 still exhibits the behavior (and now seems to give less logs 😒 ):

 Run TG908/fork-sync@v1.2
13s
    pr_title: Fork Sync
Run TG908/fork-sync@v1.2
  with:
    github_token: ***
    owner: llvm
    base: master
    head: master
    merge_method: merge
    pr_title: Fork Sync
##[error]Failed to create or merge pull request: HttpError: Server Error

Thank you for the follow up. I fixed another error with the retry plugin in version 1.2.1. I hope this will finally fix the issue.

Hmm after using 1.2.1 I'm seeing some spurious failures:

Run TG908/fork-sync@v1.2.1
  with:
    github_token: ***
    owner: llvm
    base: master
    head: master
    merge_method: merge
    pr_title: Fork Sync
##[error]Failed to create or merge pull request: HttpError: Pull Request is not mergeable

But it looks like we're not behind, either? Is it possible the task is still erroring out and still retrying?

So there was an error and the PR got merged anyway. Weird...

Definitely still seeing frequent pop ups of:

Run TG908/fork-sync@v1.2.1
##[error]Failed to create or merge pull request: HttpError: Pull Request is not mergeable

with a PR that isn't merged, and the next job runs into:

Run TG908/fork-sync@v1.2.1
##[error]Failed to create or merge pull request: HttpError: Validation Failed: {"resource":"PullRequest","code":"custom","message":"A pull request already exists for llvm:master."}

If I don't catch it soon enough.

I'm wondering now if there needs to be a little bit more delay between the creation of the pull request, and the merge? Seems like with large PRs it's taking GitHub awhile to mark it as "ready to be merged". Not sure the best way to fix that, but I also wonder if we can get it to try, and merge an existing PR if it sees one already exists? That way while it may fail creating a new PR, the next run will get it, and merge it?

Thanks for the feedback πŸ˜„. I have increased the retry count to 6 and set the delay to 10 seconds. I don't like the idea of merging any open pull request. How will we know it is a PR created by fork sync? It might be good to at least close PRs that cannot be merged in a separate try/catch block. Let me know if the values need more tweaking.

I was thinking identifying the by branch/username, but if we want to avoid that; that's fine I think.

Is there a new release for these values or should I switch to the HEAD branch to make sure they're picked up?

Tags v1, v1.2 and v1.2.1 should have the change

Ah great, I'll leave it running, and let you know what we see. Thanks so much for doing all this, really appreciated.

Unfortunately it looks like problems have continued as before (maybe even more failures). Out of about the 4~5 jobs that ran:

  • 2 Failed while still merging a PR with "Failed to create or merge pull request: HttpError: Pull Request is not mergeable", while still actually merging a PR?
  • 1 Failed, and didn't create a PR at all.
  • 1 Succeeded.

Unsure what other actions can be taken at this point 😞

It looks like the actions didn't fail due to the PRs not being ready like before. HttpError: Pull Request is not mergeable seems like there are conflicts which need to be resolved which we cannot do in the action.

I think the error message is misleading here.

There are no conflicts between the branches. as shown by re running the actions, and having them succeed, or by sometimes the pull requests still actually being merged.

(This has also been the same error message throughout, ever since the first round of upgrades).

[...] or by sometimes the pull requests still actually being merged.
This is really odd. I have no clue why this would happen. The retry plugin works in weird ways ...

I've yet again increased the retry delay to 30 seconds in v1.2.3 and added a debug log for the retry count in v1.2.4.
Might be interesting to see how many times it actually retries the request.

Using v1.2.4, this morning I got a pr that is open, but not merged (though I was able to successfully hit the merge button, there are no checks on the repo so that wouldn't be blocking). The logs were:

Run TG908/fork-sync@v1.2.4
  with:
    github_token: ***
    owner: llvm
    base: master
    head: master
    merge_method: merge
    pr_title: Fork Sync
request failed after 4 retries
Error: Failed to create or merge pull request: HttpError: Pull Request is not mergeable

I had some of my actions fail as well. For for retries with a delay of 30 seconds the action should run at least 120 seconds. Mine only ran for 46s. Maybe the delay is not set properly. I added some more logging in 1.2.5

Maybe the delay is only for the first retry. I added a sleep of 5 seconds before merging maybe that'll do the trick.

So looking at logs today we had a pull request still get merged (but the step marked as a failure). The logs were:

Run TG908/fork-sync@v1.2.6
  with:
    github_token: ***
    owner: llvm
    base: master
    head: master
    merge_method: merge
    pr_title: Fork Sync
request failed after 4 retries with a delay of 25
Error: Failed to create or merge pull request: HttpError: Pull Request is not mergeable

and it ran for 49 seconds.

Leaving it running for a bit, it seems I'm in a pretty constant state now of: "Marked as failure", but the PR is merged and updated. Seems pretty constant. So besides the emails from GitHub it's not a huge thing. Just a minor annoyance.

The retry plugin is still not working as I expect it to work. Only thing I can do now is increase the wait and hope this issue will occur less.

this seems fixed πŸ₯³