cloudflare / wrangler-action

🧙‍♀️ easily deploy cloudflare workers applications using wrangler and github actions
Apache License 2.0
1.27k stars 160 forks source link

v3.12.1 on external CI/CD - ReferenceError: crypto is not defined #329

Closed b-tuma closed 1 week ago

b-tuma commented 1 week ago

Hi,

I have a Gitea action runner using docker://ghcr.io/catthehacker/ubuntu:act-latest that fails when running wrangler-action@v3.12.1 with the following message:

2024-11-19T20:12:18.2339725Z file:///run/act/actions/https---github.com-cloudflare-wrangler-action@v3/dist/index.mjs:33086
2024-11-19T20:12:18.2340203Z     WRANGLER_OUTPUT_DIR: `${(0,external_path_.join)((0,external_os_.tmpdir)(), `wranglerArtifacts-${crypto.randomUUID()}`)}`,
2024-11-19T20:12:18.2340386Z                                                                                                     ^
2024-11-19T20:12:18.2340556Z 
2024-11-19T20:12:18.2340696Z ReferenceError: crypto is not defined
2024-11-19T20:12:18.2340848Z     at file:///run/act/actions/https---github.com-cloudflare-wrangler-action@v3/dist/index.mjs:33086:101
2024-11-19T20:12:18.2341007Z     at file:///run/act/actions/https---github.com-cloudflare-wrangler-action@v3/dist/index.mjs:33376:3
2024-11-19T20:12:18.2341175Z     at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
2024-11-19T20:12:18.2341327Z     at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
2024-11-19T20:12:18.2341493Z     at async loadESM (node:internal/process/esm_loader:34:7)
2024-11-19T20:12:18.2341699Z     at async handleMainPromise (node:internal/modules/run_main:106:12)
2024-11-19T20:12:18.2341897Z 
2024-11-19T20:12:18.2342086Z Node.js v18.20.4
2024-11-19T20:12:18.2494544Z exitcode '1': failure

Rolling back to v3.12.0 solved the issue, so I assume this is related to the new crypto addition on #318.

jahands commented 1 week ago

Hi!

This Action needs to run using Node 20, as specified in action.yml. It looks like Gitea (or the image you're using) are not respecting this value, and instead running it with Node 18.

I would recommend raising this either on the Gitea repo, or the repo for the image you're using (not 100% sure which is more appropriate, but probably start by raising with Gitea.)

Sorry for the inconvenience.