mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-11 10:40:53 -04:00
perf: only log download progress for big tarballs
This commit is contained in:
5
.changeset/honest-bananas-doubt.md
Normal file
5
.changeset/honest-bananas-doubt.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/tarball-fetcher": minor
|
||||
---
|
||||
|
||||
Download progress should be logged only for big tarballs.
|
||||
@@ -12,6 +12,8 @@ import { BadTarballError } from './errorTypes'
|
||||
import urlLib = require('url')
|
||||
import ssri = require('ssri')
|
||||
|
||||
const BIG_TARBALL_SIZE = 1024 * 1024 * 5 // 5 MB
|
||||
|
||||
class TarballIntegrityError extends PnpmError {
|
||||
public readonly found: string
|
||||
public readonly expected: string
|
||||
@@ -149,7 +151,9 @@ export default (
|
||||
if (opts.onStart) {
|
||||
opts.onStart(size, currentAttempt)
|
||||
}
|
||||
const onProgress = opts.onProgress
|
||||
// In order to reduce the amount of logs, we only report the download progress of big tarballs
|
||||
const onProgress = size != null && size >= BIG_TARBALL_SIZE
|
||||
? opts.onProgress : undefined
|
||||
let downloaded = 0
|
||||
res.body.on('data', (chunk: Buffer) => {
|
||||
downloaded += chunk.length
|
||||
|
||||
Reference in New Issue
Block a user