Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies cannot be installed in version 3.6.0 #264

Closed
tomaco-gojiraf opened this issue May 23, 2024 · 10 comments
Closed

Dependencies cannot be installed in version 3.6.0 #264

tomaco-gojiraf opened this issue May 23, 2024 · 10 comments
Assignees

Comments

@tomaco-gojiraf
Copy link

tomaco-gojiraf commented May 23, 2024

I was deploying normally and suddenly my pipeline started to fail, and it just happened to coincide with the release of the new action version (3.6.0).
It fails when trying to install the package.json dependencies throwing an error that it cannot resolve the dependency. The error is thrown on the import line of the code and advises you to mark it as external to fix it, but this sounded strange to me because it was already working this way.

✘ [ERROR] Could not resolve "@tsndr/cloudflare-worker-jwt"

src/auth/validate-token.ts:1:23:
1 │ import { verify } from '@tsndr/cloudflare-worker-jwt';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can mark the path "@tsndr/cloudflare-worker-jwt" as external to exclude it from the bundle, which will remove this error.

The same error happens with zod dependency:

Could not resolve "zod"

Using the action version 3.5.0 fixed the problem quickly.

I also tried using bun as a package manager thinking it might be a npm problem, but it didn't fix anything.

GitHub Action:

name: Deploy Production

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy
    environment: production
    steps:
      - uses: actions/checkout@v4

      - name: Deploy
        uses: cloudflare/wrangler-action
        with:
          apiToken: ${{ secrets.CF_API_TOKEN }}
          accountId: ${{ secrets.CF_ACCOUNT_ID }}
          wranglerVersion: 3.57.1
          secrets: |
            SECRET_KEY
        env:
          SECRET_KEY: ${{ secrets.SECRET_KEY }}
@edgeboy47
Copy link

+1

@Maximo-Guk
Copy link
Member

Maximo-Guk commented May 23, 2024

Hey @tomaco-gojiraf and @edgeboy47 👋!

I can't reproduce dependency installation issues using the new action version 3.6.0 on my repository.

From the logs you linked it looks to me like it may be a package installation issue, I would double check that zod and @tsndr/cloudflare-worker-jwt are both in your package.json and that's you've ran npm install.

Would it be possible for one you to provide me with a reproduction repository that has this issue?

Thank you! 🙏

@svrnhdl
Copy link

svrnhdl commented May 23, 2024

Same issue here. Had an old worker on wrangler version 3.23.0 that I updated to 3.57.1 with wrangler-action@v3. Weird thing was that Github Actions was still using 3.23.0 for a while and then suddenly stopped working when it installed 3.57.1.

downgrading to action version 3.5.0 fixed it.
image

@kchro3
Copy link

kchro3 commented May 23, 2024

+1 that i'm seeing this issue too with multiple packages:


    ...: ERROR: Could not resolve "@tsndr/cloudflare-worker-jwt"
    ...: ERROR: Could not resolve "hono/streaming"
    ...: ERROR: Could not resolve "openai"
    ...: ERROR: Could not resolve "@anthropic-ai/sdk"
    ...: ERROR: Could not resolve "postgres"

I would double check that zod and @tsndr/cloudflare-worker-jwt are both in your package.json and that's you've ran npm install

it was working fine a couple days ago, so pretty sure it's not a package issue / npm install issue.

Also can confirm that downgrading to v3.5.0 works:

jobs:
  deploy:
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v4
      - name: Build & Deploy Worker
        uses: cloudflare/[email protected]
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

@AdiRishi
Copy link
Contributor

A reproduction repository would be very helpful 🙏
I just upgraded three different repos I have to 3.6.0 and it's worked everywhere.

Also, some context on what wrangler-action was doing when it failed would be good. Here are some of the steps that run.

🔍 Checking for existing Wrangler installation
📥 Installing Wrangler (only run if installation is necessary)
🔑 Uploading secrets...
🚀 Running Wrangler Commands

Some questions

  • Was it trying to install wrangler?
  • If it was trying to install wrangler, is it using the correct package maanger?
  • Do you expect it to install wrangler? The new change in 3.6.0 will use your local wrangler version if it's present.

@sakettawde
Copy link

Adding context since am facing a similar issue.

Absolutely nothing changed in my code. It started failing today.

Issue seen:
image

Changed my github workflow file by specifying to use v3.5 for wrangler-action as below:
image

And now it runs as before. Screengrab of logs below:
image

@hiendaovinh
Copy link

I've the same issue. Pinning to v3.5.0 helps for now.

@AdiRishi
Copy link
Contributor

AdiRishi commented May 24, 2024

Oh, I see what happened. Thanks for the screenshots @sakettawde .
In 3.6.0 we released a new feature which would check for an existing wrangler installation, and use it if appropriate.

The code which checks for an existing installation runs npx wrangler --version to determine if wrangler is installed. What I missed was that this command will automatically install the latest version of wrangler if no version is installed 🙃

This means that by accident wrangler-action now always will install the latest wrangler if you don't specify wranglerVersion in the config. This is a breaking change and bug, since we meant for it to keep it's old behavior and install version 3.13.2 by default.

For everyone who's build is now failing, I suspect your codebase has something about it which requires that older version of wrangler, since wrangler deploy fails for you when using version 3.57.1. In order to restore previous behavior, simply pin wranglerVersion to 3.13.2 like this

jobs:
  deploy:
    steps:
      uses: cloudflare/wrangler-action@v3
      with:
        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
        wranglerVersion: "3.13.2"

I'll work on making a PR to fix this issue.

@Rohan487
Copy link

image

+1

@Maximo-Guk
Copy link
Member

Hello 👋

We ended up reverting #235 in v3.6.1 to prevent breaking changes for users on old versions of wrangler who inadvertently were now using the latest version of wrangler due to not having it specified.

We will look into fixing this in a follow up because it would be fantastic if we could check for an existing wrangler installation, and install it correctly.

Let us know if you're still experiencing these issues after upgrading to v3.6.1

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants