Wandalen / wretry.action

Retry action for Github CI
MIT License
93 stars 20 forks source link

`ERR_REQUIRE_ESM` error when running node16 actions #120

Closed bagusnl closed 5 months ago

bagusnl commented 10 months ago

Hello, I am trying to implement wretry.action into our workflow to sync our files into an r2 bucket using ryand56's r2-upload-action since syncing to an r2 bucket is quite flaky. Though seems like I got a roadblock ahead with ERR_REQUIRE_ESM error that I got (details below). For disclaimer, I am not quite familiar with Node or JavaScript in general but feel free to ask something that you might need to investigate this issue.

GitHub workflow file: https://github.com/neon-nyan/CollapseLauncher-ReleaseRepo/actions/runs/6687813790/workflow Failed Workflow log: https://github.com/neon-nyan/CollapseLauncher-ReleaseRepo/actions/runs/6687813790/job/18168980627

Actions used: https://github.com/ryand56/r2-upload-action Workflow command example:

      - name: Sync repair_indexes
        uses: Wandalen/wretry.action@master
        if: always()
        with:
          attempt_limit: 3
          attempt_delay: 30000
          action: ryand56/r2-upload-action@latest
          with: |
            r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
            r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
            r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
            r2-bucket: ${{ secrets.R2_BUCKET }}
            source-dir: cl-cdn/metadata/repair_indexes
            destination-dir: cl-cdn/metadata/repair_indexes
            output-file-url: false

Error log snippet:

/home/runner/work/_actions/Wandalen/wretry.action/v1.3.0_js_action/src/Runner.js:21
  require( process.argv[ 2 ] )
  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/_actions/Wandalen/r2-upload-action/dist/index.js from /home/runner/work/_actions/Wandalen/wretry.action/v1.3.0_js_action/src/Runner.js not supported.
Instead change the require of index.js in /home/runner/work/_actions/Wandalen/wretry.action/v1.3.0_js_action/src/Runner.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/runner/work/_actions/Wandalen/wretry.action/v1.3.0_js_action/src/Runner.js:21:3) {
  code: 'ERR_REQUIRE_ESM'
}
Error: Process returned exit code 1
Launched as "/home/runner/runners/2.[311](https://github.com/neon-nyan/CollapseLauncher-ReleaseRepo/actions/runs/6687813790/job/18168980627#step:6:313).0/externals/node16/bin/node /home/runner/work/_actions/Wandalen/wretry.action/v1.3.0_js_action/src/Runner.js /home/runner/work/_actions/Wandalen/r2-upload-action/dist/index.js"
Launched at "/home/runner/work/CollapseLauncher-ReleaseRepo/CollapseLauncher-ReleaseRepo"
dmvict commented 10 months ago

Hello @bagusnl

I'll look at the issue when I have time.

eric2788 commented 7 months ago

same problem here

dmvict commented 5 months ago

Hello @bagusnl and @eric2788

Can you try the new version of action and give me a feedback? I made a lot of changes and it can solve the issue.

bagusnl commented 5 months ago

Hi, sorry it takes awhile for me to try it again. But unfortunately it did not fixed it and outputs pretty much the same error

Workflow example:

      - name: Sync Squirrel\Preview folder
        uses: Wandalen/wretry.action@master
        with:
          attempt_limit: 3
          attempt_delay: 10000
          action: ryand56/r2-upload-action@latest
          with: |
            r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
            r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
            r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
            r2-bucket: ${{ secrets.R2_BUCKET }}
            source-dir: squirrel-preview/cl-cdn/squirrel/preview
            destination-dir: cl-cdn/squirrel/preview
            output-file-url: false

Error output:

/home/runner/work/_actions/Wandalen/wretry.action/v3.0.0_js_action/src/Runner.js:21
  require( process.argv[ 2 ] )
  ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/_actions/Wandalen/r2-upload-action/dist/index.js from /home/runner/work/_actions/Wandalen/wretry.action/v3.0.0_js_action/src/Runner.js not supported.
Instead change the require of index.js in /home/runner/work/_actions/Wandalen/wretry.action/v3.0.0_js_action/src/Runner.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/runner/work/_actions/Wandalen/wretry.action/v3.0.0_js_action/src/Runner.js:21:3) {
  code: 'ERR_REQUIRE_ESM'
}
Node.js v20.8.1
dmvict commented 5 months ago

Hello @bagusnl

I fixed the issue in the new release v3.0.1.