mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-18 13:51:38 -04:00
feat: new setting - maxsockets (#3889)
This commit is contained in:
5
.changeset/silent-tables-reflect.md
Normal file
5
.changeset/silent-tables-reflect.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@pnpm/store-connection-manager": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Make the maximum amount of sockets configurable through the `maxSockets` option.
|
||||||
5
.changeset/swift-readers-repeat.md
Normal file
5
.changeset/swift-readers-repeat.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@pnpm/config": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
New setting supported: maxsockets. maxsockets allows to set the maximum number of connections to use per origin (protocol/host/post combination).
|
||||||
@@ -96,6 +96,7 @@ export interface Config {
|
|||||||
storeDir?: string
|
storeDir?: string
|
||||||
virtualStoreDir?: string
|
virtualStoreDir?: string
|
||||||
verifyStoreIntegrity?: boolean
|
verifyStoreIntegrity?: boolean
|
||||||
|
maxSockets?: number
|
||||||
networkConcurrency?: number
|
networkConcurrency?: number
|
||||||
fetchingConcurrency?: number
|
fetchingConcurrency?: number
|
||||||
lockfileOnly?: boolean // like npm's --package-lock-only
|
lockfileOnly?: boolean // like npm's --package-lock-only
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export const types = Object.assign({
|
|||||||
'lockfile-directory': String, // TODO: deprecate
|
'lockfile-directory': String, // TODO: deprecate
|
||||||
'lockfile-only': Boolean,
|
'lockfile-only': Boolean,
|
||||||
loglevel: ['silent', 'error', 'warn', 'info', 'debug'],
|
loglevel: ['silent', 'error', 'warn', 'info', 'debug'],
|
||||||
|
maxsockets: Number,
|
||||||
'modules-cache-max-age': Number,
|
'modules-cache-max-age': Number,
|
||||||
'modules-dir': String,
|
'modules-dir': String,
|
||||||
'network-concurrency': Number,
|
'network-concurrency': Number,
|
||||||
@@ -224,6 +225,10 @@ export default async (
|
|||||||
...Object.entries(cliOptions).filter(([name, value]) => typeof value !== 'undefined').map(([name, value]) => [camelcase(name), value]),
|
...Object.entries(cliOptions).filter(([name, value]) => typeof value !== 'undefined').map(([name, value]) => [camelcase(name), value]),
|
||||||
]) as unknown as ConfigWithDeprecatedSettings
|
]) as unknown as ConfigWithDeprecatedSettings
|
||||||
const cwd = (cliOptions.dir && path.resolve(cliOptions.dir)) ?? npmConfig.localPrefix
|
const cwd = (cliOptions.dir && path.resolve(cliOptions.dir)) ?? npmConfig.localPrefix
|
||||||
|
|
||||||
|
pnpmConfig.maxSockets = npmConfig.maxsockets
|
||||||
|
delete pnpmConfig['maxsockets']
|
||||||
|
|
||||||
pnpmConfig.workspaceDir = opts.workspaceDir
|
pnpmConfig.workspaceDir = opts.workspaceDir
|
||||||
pnpmConfig.workspaceRoot = cliOptions['workspace-root'] as boolean // This is needed to prevent pnpm reading workspaceRoot from env variables
|
pnpmConfig.workspaceRoot = cliOptions['workspace-root'] as boolean // This is needed to prevent pnpm reading workspaceRoot from env variables
|
||||||
pnpmConfig.rawLocalConfig = Object.assign.apply(Object, [
|
pnpmConfig.rawLocalConfig = Object.assign.apply(Object, [
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export type CreateNewStoreControllerOptions = CreateResolverOptions & Pick<Confi
|
|||||||
| 'httpsProxy'
|
| 'httpsProxy'
|
||||||
| 'key'
|
| 'key'
|
||||||
| 'localAddress'
|
| 'localAddress'
|
||||||
|
| 'maxSockets'
|
||||||
| 'networkConcurrency'
|
| 'networkConcurrency'
|
||||||
| 'noProxy'
|
| 'noProxy'
|
||||||
| 'offline'
|
| 'offline'
|
||||||
@@ -64,9 +65,11 @@ export default async (
|
|||||||
strictSsl: opts.strictSsl ?? true,
|
strictSsl: opts.strictSsl ?? true,
|
||||||
timeout: opts.fetchTimeout,
|
timeout: opts.fetchTimeout,
|
||||||
userAgent: opts.userAgent,
|
userAgent: opts.userAgent,
|
||||||
maxSockets: opts.networkConcurrency != null
|
maxSockets: opts.maxSockets ?? (
|
||||||
? (opts.networkConcurrency * 3)
|
opts.networkConcurrency != null
|
||||||
: undefined,
|
? (opts.networkConcurrency * 3)
|
||||||
|
: undefined
|
||||||
|
),
|
||||||
})
|
})
|
||||||
await fs.mkdir(opts.storeDir, { recursive: true })
|
await fs.mkdir(opts.storeDir, { recursive: true })
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user