Many common request errors can be easily remediated by retrying the request. We recommend installing the @octokit/plugin-retry plugin for Automatic retries in these cases

const { Octokit } = require("@octokit/rest");
const { retry } = require("@octokit/plugin-retry");
const MyOctokit = Octokit.plugin(retry);
const octokit = new MyOctokit();
// all requests sent with the `octokit` instance are now retried up to 3 times for recoverable errors.