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

Error on deploy command due to regression on dependency(prettyjson) #4012

Closed
dongm2ez opened this issue Jan 11, 2022 · 12 comments
Closed

Error on deploy command due to regression on dependency(prettyjson) #4012

dongm2ez opened this issue Jan 11, 2022 · 12 comments
Labels
type: bug code to address defects in shipped code

Comments

@dongm2ez
Copy link

dongm2ez commented Jan 11, 2022

Describe the bug

Run netlify deploy --prod --dir dist

  System:
    OS: macOS 12.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
    Memory: 2.96 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.3.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.3.0 - /usr/local/bin/npm

CLI Output

›   RangeError: Invalid array length
@dongm2ez dongm2ez added the type: bug code to address defects in shipped code label Jan 11, 2022
@Uhiyamind
Copy link

Uhiyamind commented Jan 11, 2022

I am having the same problem.
I get a "RangeError" when deploying from CircleCI to Netlify. I can't see the detail log so I can't figure out the cause.

The build timed out due to an infinite loop bug in colors.js. Since then, all deployments have failed.
Now colors.js has been fixed to 1.4.0, but I still can't deploy it.

I hope the problem will be resolved.

@MarkMekhaiel
Copy link

Same symptoms as above, we're unable to deploy since yesterday.

@AidanDaniel97
Copy link

Exact same issue here, first the colors.js issue and now this - haven't been able to find out exactly what is triggering the error. At first I thought it might have been something within my nuxt site but after testing it on a branch I knew worked before, I got the same error.

@grouville
Copy link

grouville commented Jan 11, 2022

Yeah, we need to bump prettyjson to latest version. They've been trying to mitigate: https://snyk.io/blog/open-source-maintainer-pulls-the-plug-on-npm-packages-colors-and-faker-now-what.

Once #4005 gets merged, it will be fixed (tested locally)

@dakshshah96
Copy link

I was just able to run this on my local environment and deploy successfully after building locally:

sudo netlify deploy --dir=dist --prod --auth XXXXX —site XXXXX

Running the same command on GitHub Actions gives me the same error as others:

›   RangeError: Invalid array length

@grouville
Copy link

oy successfully after building locally

oh, so you only built netlify locally and it worked ? No changes in the prettyjson version ?

@dakshshah96
Copy link

@grouville All I did was install a fresh copy of Netlify CLI (npm install netlify-cli -g) on my local environment, and ran the deploy command.

@erezrokah erezrokah changed the title RangeError: Invalid array length Error on deploy command due to regression on dependency(prettyjson) Jan 11, 2022
@erezrokah
Copy link
Contributor

Hi everyone, we're currently looking into this. This is a duplicate of #4011 but will keep this one as it has a discussion.

We use a shrinkwrap file, which means we pin dependencies at publication, so if you use npm to install you should get working versions of colors and prettyjson, as we haven't updated any of those yet:

➜  cli git:(main) npm ls prettyjson
netlify-cli@8.6.18 /Users/erezrokah/Code/github/netlify/cli
└── prettyjson@1.2.1

I'll try to reproduce, but if some can post a step by step reproduction scenario that would be great.

@dakshshah96
Copy link

dakshshah96 commented Jan 11, 2022

@erezrokah Here's what my GitHub Actions workflow looks like. The RangeError occurs on the last job. I'll try reproducing this on a minimal repo and update.

name: Deployment
on:
  push:
    branches:
      - master

jobs:
  deploy_pwa:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: packages/pwa
    steps:
    - name: Checkout source code
      uses: actions/checkout@v2
    
    - name: Use Node.js 12.x
      uses: actions/setup-node@v2-beta
      with:
        node-version: '12.x'

    - name: Cache dependencies
      uses: actions/cache@v2
      id: cache
      with:
        path: |
          node_modules
          */*/node_modules
        key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

    - name: Install dependencies
      if: steps.cache.outputs.cache-hit != 'true'
      run: yarn

    - name: Build
      run: yarn run build

    - name: Install netlify-cli
      run: sudo yarn global add netlify-cli

    - name: Publish on Netlify
      run: DEBUG=* sudo netlify deploy --dir=dist --prod --auth $NETLIFY_AUTH_TOKEN --site $NETLIFY_SITE_ID
      env:
        NETLIFY_AUTH_TOKEN: ${{ env.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ env.NETLIFY_SITE_ID }}

==============

UPDATE: Looks like this happens because I'm using Yarn in my GitHub Actions workflow whereas I was using npm while installing locally on my machine. Yarn doesn't support the shrinkfile file as mentioned in #3981 (comment).

@erezrokah
Copy link
Contributor

erezrokah commented Jan 11, 2022

Thanks for the additionally information @dakshshah96, it makes sense. It's highly recommended to use yarn with a lock file.
That will pin dependencies in your CI builds and ensure they are reproducible.

To do it, you should commit the yarn.lock file to git and run yarn install --frozen-lockfile instead of yarn. See more in https://classic.yarnpkg.com/en/docs/cli/install/.

To install the CLI globally in a reproducible way, you should switch to npm (npm install -g netlify-cli). However in CI we do recommend installing locally, as by running npm install -g netlify-cli you're opting into breaking changes of the CLI.

@erezrokah
Copy link
Contributor

Regardless I believe this issue can be closed as it was resolved in the latest prettyjson version. See #4011 (comment)

@Uhiyamind
Copy link

I updated netlify-cli to v8.6.19 and the problem was solved. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

7 participants