navikt / ghep

Github Event Pusher
MIT License
2 stars 2 forks source link

Redeliver script har sluttet å fungere #41

Open Kyrremann opened 6 months ago

Kyrremann commented 6 months ago

Koden fra Github har sluttet å fungere: https://docs.github.com/en/webhooks/using-webhooks/automatically-redelivering-failed-deliveries-for-a-github-app-webhook

Får feil med Javascript import, og endring av det gjør at noe annet feiler.

Fikser man denne feilen:


const { App, Octokit } = require("octokit");
                         ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/ghep/ghep/node_modules/octokit/dist-bundle/index.js from /home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js not supported.
Instead change the require of index.js in /home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js:2:26) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.20.2```

Får man denne feilen:
``` /home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js:18
  const app = new App({
              ^

TypeError: App is not a constructor
    at checkAndRedeliverWebhooks (/home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js:18:15)
    at /home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js:210:9
    at Object.<anonymous> (/home/runner/work/ghep/ghep/.github/workflows/scripts/redeliver-failed-deliveries.js:211:3)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49

Node.js v18.20.2```
Kyrremann commented 3 months ago

Løst i https://github.com/navikt/ghep/commit/9190ff4bfb7ba0cb6e3efcda311e295c1e7ce1e3 og endring av script til .mjs.