action-setup: Pipelines fail with `SyntaxError: Unexpected token`

Hi, we see occasional failed pipelines because, well, something goes wrong in pnpm/action-setup:

Running self-installer...
  [stdin]:1
  <HTML>
  ^
  SyntaxError: Unexpected token '<'
      at new Script (vm.js:84:7)
      at createScript (vm.js:258:10)
      at Object.runInThisContext (vm.js:306:10)
      at Object.<anonymous> ([stdin]-wrapper:9:26)
      at Module._compile (internal/modules/cjs/loader.js:959:30)
      at evalScript (internal/process/execution.js:80:25)
      at internal/main/eval_stdin.js:29:5
      at Socket.<anonymous> (internal/process/execution.js:192:5)
      at Socket.emit (events.js:215:7)
      at endReadableNT (_stream_readable.js:1184:12)
Error: Something does wrong, self-installer exits with code 1
Installation Completed!
Running pnpm recursive install --frozen-lockfile
Error: Command pnpm recursive install --frozen-lockfile (cwd: undefined) exits with status 127

I’m not sure if it’s this line const response = await fetch('https://pnpm.js.org/pnpm.js') that might fail? If it somehow gets an HTML response? So if pnpm.js.org fails to return the pnpm.js script for a splitsecond, instead returning an HTML error page, then that could happen?

Will maintainers consider a retry mechanism to increase resilience? If the request is the cause of this error then an exponential backoff could work well, to try a couple times before giving up. WDYT?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

🚢 2.2.2

Can’t we just commit that file to this repository?

I have also configured cloudflare caching, so I don’t think this will happen again

https://github.com/pnpm/get.pnpm.io/commit/08d49fa45705eb0c1b788b155be449969795c311

how does changing fetch’s url and checking response’s body can help to prevent server responding false js file?

changing the URL is unrelated. It was just an old version, so I updated it.

The fix is in using @fetch/retry. When this issue happens, the HTTP response is a 500. @fetch/retry retries the request in this case.

We run multiple jobs in parallel so now I suspect we’re being ratelimited by the jobs starting in parallel that all download pnpm.js

I tried downloading multiple pnpm.js concurrently (30 requests) but all of them were valid JavaScript files.

Anyway, I will leave this issue open for a month or two. If there is a problem, let me know.