Git Product home page Git Product logo

Comments (3)

isaacs avatar isaacs commented on July 23, 2024 1

I think this was a result of a legitimate networking timeout issue on the registry that happened around that time. Or, something else is going on.

I couldn't reproduce the problem with the package.json you provided. So, I thought, let's push it further. Like, as far as it'll go. Let's fetch every packument.

const pacote = require('../')
const https = require('https')
const fs = require('fs')
const pMap = require('p-map');

const runTest = ({rows}) => {
  console.error(`Starting test with ${rows.length} packuments`)
  let i = 0
  pMap(rows, ({id}) => pacote.packument(id).then(result => {
    if (++i % 1000 === 0)
      console.error(`fetched ${i} successfully`)
  }).catch(er => {
    if (er.code !== 'E404') {
      // 404 errors for unpublished packages are normal and expected
      throw er
    }
  }), { concurrency: 8 }).then(() => console.log('ok!'))
}

// cache the file since it takes a long time
try {
  const allDocs = JSON.parse(fs.readFileSync(__dirname + '/all_docs.json', 'utf8'))
  console.error('running test with cached all_docs')
  runTest(allDocs)
} catch (_) {
  console.error('did not get cached all_docs', _)
  https.get('https://replicate.npmjs.com/_all_docs', res => {
    const body = []
    res.on('data', c => body.push(c))
    res.on('end', () => {
      const buf = Buffer.concat(body)
      fs.writeFileSync(__dirname + '/all_docs.json', buf)
      runTest(JSON.parse(buf.toString()))
    })
  })
}

This took quite some time to finish, but it did finish successfully, downloading 1264179 packuments with a concurrency of 8.

I even bumped the concurrency up to 10,000, and it still crunched through it all without hitting a network timeout.

🤷‍♂️

from pacote.

abnud1 avatar abnud1 commented on July 23, 2024

@isaacs Did you try on a slow network ? Mine was 1Mbps .

And thanks for the Hard Work

from pacote.

isaacs avatar isaacs commented on July 23, 2024

Well, right, if you're on a slow enough network, it'll time out sometimes. The point is, it's not pacote forcing it to time out by keeping connections open for old requests when a lot of requests are made, so as far as I can tell, not a bug in this module.

If you're on a slow network, I recommend setting opts.retry which is passed through to make-fetch-happen. If you set a very high opts.retry.retries and opts.retry.maxTimeout, and set a high opts.timeout option, then you can tune it to the expected time before your network can be reasonably expected to return a result.

Since this is legitimately your network taking longer than your configs are allowing for, an ETIMEOUT is the correct error, and I think pacote and make-fetch-happen are working as designed. (Also note that it'll only hit this after retrying a few times, so transient errors shouldn't be a major problem.)

from pacote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.