Skip to content

Commit 30c7590

Browse files
fix: shorten CAFS temp directory names (#12327)
## Summary - use `fs.mkdtemp()` with a short `_tmp_` prefix for CAFS temporary package directories - remove `path-temp` from `@pnpm/store.create-cafs-store` - add git-fetcher regression coverage for short CAFS temp directories during git package preparation - add a patch changeset for `@pnpm/store.create-cafs-store` and `pnpm` ## Why This leaves more Unix socket path budget for lifecycle tools that create IPC sockets under `TMPDIR` during git-hosted dependency preparation. Closes #12222. ## Pacquet No pacquet change is included because the Rust git fetcher already uses `tempfile::tempdir()` instead of the TypeScript CAFS `path-temp` suffix changed here.
1 parent b4194aa commit 30c7590

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

.changeset/short-pipes-dance.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@pnpm/store.create-cafs-store": patch
3+
"pnpm": patch
4+
---
5+
6+
Create shorter CAFS temporary package directories to leave room for lifecycle scripts that create IPC socket paths under TMPDIR.

fetching/git-fetcher/test/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ beforeEach(() => {
4747
jest.mocked(globalWarn).mockClear()
4848
})
4949

50+
test('uses short CAFS temp directories for git package preparation', async () => {
51+
const storeDir = temporaryDirectory()
52+
const tmpDir = await createCafsStore(storeDir).tempDir()
53+
54+
expect(path.dirname(tmpDir)).toBe(path.join(storeDir, 'tmp'))
55+
expect(path.basename(tmpDir)).toMatch(/^_tmp_[a-zA-Z0-9]{6}$/)
56+
expect(path.basename(tmpDir).length).toBeLessThanOrEqual(11)
57+
})
58+
5059
test('fetch', async () => {
5160
const storeDir = temporaryDirectory()
5261
const fetch = createGitFetcher({ storeIndex: createStoreIndex(storeDir) }).git

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

store/create-cafs-store/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@pnpm/store.cafs": "workspace:*",
4949
"@pnpm/store.controller-types": "workspace:*",
5050
"memoize": "catalog:",
51-
"path-temp": "catalog:",
5251
"ramda": "catalog:"
5352
},
5453
"peerDependencies": {

store/create-cafs-store/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {
1414
ImportPackageFunctionAsync,
1515
} from '@pnpm/store.controller-types'
1616
import memoize from 'memoize'
17-
import { pathTemp } from 'path-temp'
1817

1918
export { type CafsLocker }
2019

@@ -140,9 +139,8 @@ export function createCafsStore (
140139
storeDir,
141140
importPackage,
142141
tempDir: async () => {
143-
const tmpDir = pathTemp(baseTempDir)
144-
await fs.mkdir(tmpDir, { recursive: true })
145-
return tmpDir
142+
await fs.mkdir(baseTempDir, { recursive: true })
143+
return fs.mkdtemp(path.join(baseTempDir, '_tmp_'))
146144
},
147145
}
148146
}

0 commit comments

Comments
 (0)