act10ns / slack

Slack messages for GitHub Action workflows, jobs and steps
https://github.com/marketplace/actions/slack-github-actions-slack-integration
MIT License
191 stars 58 forks source link

Handle Slack errors #196

Open scriptin opened 3 years ago

scriptin commented 3 years ago

Hello,

One of our jobs has this as the last step:

    - uses: act10ns/slack@v1
      with:
        status: ${{ job.status }}
        channel: '#build-notifications'
      if: always()

In one build, this step failed with a following error:

Error: A request error occurred: read ECONNRESET
Error: Error: A request error occurred: read ECONNRESET
    at Object.requestErrorWithOriginal (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:2694:33)
    at IncomingWebhook.send (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:2584:32)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

As a result:

I do understand that this particular error is caused by the Slack API, but the outcome is so confusing that I decided to create this issue anyway. Looking at your code, there is no error handling around IncomingWebhook.send call. I don't know if that would help, but maybe you know a way to prevent this from happening.

The best thing which comes to my mind is some basic retry strategy, which is only triggered whenever network errors like this one occur (ignoring the normal Slack errors). Something like promise-retry may be helpful.

satterly commented 2 years ago

Thanks for raising the issue. Contributions welcome.

satterly commented 2 years ago

Example retry logic can be found here ... https://github.com/elastic/kibana/pull/41160/files