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

Reporting started failing on CI #20

Open
meeroslav opened this issue Aug 24, 2022 · 4 comments
Open

Reporting started failing on CI #20

meeroslav opened this issue Aug 24, 2022 · 4 comments

Comments

@meeroslav
Copy link

meeroslav commented Aug 24, 2022

We have a nightly audit check where we run npx snync -d .. Since last night this call started failing with the following error report:

Checking dependency: classnames
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at RegistryClient.getPackageMetadataFromRegistry (file:///home/runner/.npm/_npx/0f3efbe0158474c2/node_modules/snync/src/RegistryClient.js:27:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

as seen here: https://github.com/nrwl/nx/runs/7992209443

Locally running snync works as expected (although locally we have all packages installed while on CI we only do checkout).
Strangely, classnames hasn't been published for over a year, the next package that should be checked, cliui hasb't been changed for over 2 years, and the difference between snync 1.3.3 and 1.3.2 seems to be only in README.md. Running with v1.3.2 explicitly (i.e. npx [email protected] -d .) gives the same error.

Output from https://registry.npmjs.org/classnames is valid JSON and the same goes for https://registry.npmjs.org/cliui.

Expected Behavior

Running npx snync -d . on CI not to crash.

Current Behavior

Running npx snync -d . on CI crashes.

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • Library Version used: 1.3.3 and 1.3.2
  • Node.js version (e.g. Node.js 5.4): 16.17.0
  • Operating System and version (desktop or mobile): Desktop (VM) Ubuntu 20.04.4
@meeroslav meeroslav changed the title Reporting failing on CI since version 1.3.3 Reporting started failing on CI Aug 24, 2022
@bscript
Copy link
Contributor

bscript commented Aug 29, 2022

I'm having the same issue, it's failing because the dataBuffer is always empty, and the JSON.parse will fail because it doesn't expect an empty array or a string.

Screenshot 2022-08-29 at 17 05 34

I thought maybe the issue was from undici, but I did a quick test and it was working great

'use strict'

// import undici from 'undici'
const undici = require('undici')

async function getPackageMetadataFromRegistry() {
    const { body } = await undici.request(
      `https://registry.npmjs.org/${encodeURIComponent('classname')}`,
      {
        method: 'GET',
        headers: {
          'content-type': 'application/json'
        }
      }
      
    )
    const dataBuffer = []
    for await (const data of body) {
      dataBuffer.push(data)
    }
    const packageMetadata = Buffer.concat(dataBuffer).toString('utf8')
    const packageMetadataObject = JSON.parse(Buffer.from(packageMetadata).toString('utf8'))

    console.log(packageMetadataObject)
  }
  getPackageMetadataFromRegistry()

Output

Screenshot 2022-08-29 at 17 10 41

I'll keep debugging maybe I'll find a solution.

Thank you

@meeroslav
Copy link
Author

The issue started happening when undici was updated to 5.10.0 so it might be an error there after all. Can you try with previous version and see if buffer is still empty?

bscript added a commit to bscript/snync that referenced this issue Aug 29, 2022
@bscript
Copy link
Contributor

bscript commented Aug 29, 2022

@meeroslav, it's working after updating undici to 5.10.0 👍🏻
Screenshot 2022-08-29 at 23 47 11

@lirantal
Copy link
Member

lirantal commented Sep 5, 2022

Interesting why that happens. Thanks @meeroslav and @bscript for confirming. I'll merge the PR with the update next and publish a new version.

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

3 participants