Skip to content

Commit 2a82947

Browse files
committed
fix(dlx): move variable declarations before retry guard to avoid TDZ ReferenceError
The error message in ensurePythonDlx interpolated ${lockFile} and ${pythonDir}, but both were declared after the early-return check, causing a ReferenceError (temporal dead zone) instead of the intended InputError when retryCount >= MAX_RETRIES.
1 parent d018b35 commit 2a82947

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

packages/cli/src/utils/dlx/spawn.mts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,17 +1054,16 @@ export async function ensurePython(): Promise<string> {
10541054
*/
10551055
export async function ensurePythonDlx(retryCount = 0): Promise<string> {
10561056
const MAX_RETRIES = 3
1057+
const pythonDir = getPythonCachePath()
1058+
const pythonBin = getPythonBinPath(pythonDir)
1059+
const lockFile = path.join(pythonDir, '.downloading')
10571060

10581061
if (retryCount >= MAX_RETRIES) {
10591062
throw new InputError(
10601063
`could not acquire the Python install lock after ${MAX_RETRIES} retries at ${lockFile}; another socket process may be stuck, or the lock file is stale — remove it manually and retry, or check that ${pythonDir} is writable`,
10611064
)
10621065
}
10631066

1064-
const pythonDir = getPythonCachePath()
1065-
const pythonBin = getPythonBinPath(pythonDir)
1066-
const lockFile = path.join(pythonDir, '.downloading')
1067-
10681067
if (!existsSync(pythonBin)) {
10691068
await safeMkdir(pythonDir, { recursive: true })
10701069

0 commit comments

Comments
 (0)