Dashboard › cli › Distillation
909e5222-1330-4a89-b3ae-f3578cd5b4c5["lore_tm_v1_EX08NQh9YvZ1w2IPgnAvh486PDhEgWparhMR6cfd8Tw","lore_tm_v1_A-QCdilziXswJRCotjZcaB2FUJ5XU4eU-9IGIS03kNQ","lore_tm_v1_lFhjdaSBbiDSgWiwasnoUakQSQvyQRK_kVavCV3wndo","lore_tm_v1_5s3Pfk8v9acly58mCzdBSALa4Nd7lN7APNBzxCeE9wM","lore_tm_v1_w6kpgu23pdXS_KX0AGMMfyyHjYCHKYk21XxZWqsBnro"]
packages/cli/test/preload.ts found that every preload invocation removes the entire worker-scoped TEST_TMP_DIR via rmSync(TEST_TMP_DIR, { recursive: true, force: true }) at lines 63-67, then recreates it with mkdirSync(TEST_TMP_DIR, { recursive: true }) at line 68.packages/cli/test/preload.ts creates a per-process config directory at join(TEST_TMP_DIR, \preload-${process.pid}`), assigns it to process.env.SENTRY_CONFIG_DIR, and removes only that testDiron process exit; it also exits cleanly onSIGINTandSIGTERM`.packages/cli/test/preload.ts clears Sentry environment variables, then sets SENTRY_AUTH_TOKEN="sntrys_test-token-for-unit-tests_000000", SENTRY_CLI_NO_TELEMETRY="1", and SENTRY_CLI_NO_UPDATE_CHECK="1"; it replaces globalThis.fetch with a mock that reports and throws on unmocked external calls.packages/cli/test/constants.ts defines WORKER_ID = process.env.VITEST_POOL_ID; TEST_TMP_DIR is join(tmpdir(), \sentry-cli-test-w${WORKER_ID}`)when defined andjoin(tmpdir(), "sentry-cli-test")` otherwise. The intended design is worker-scoped temp roots under parallel Vitest execution.packages/cli/test/helpers.ts; relevant uses include createTestConfigDir(), cleanupTestDir(), and fixed-name children such as upgrade-spawn-bin.packages/cli/test/helpers.ts creates TEST_TMP_DIR once at module evaluation with mkdirSync(TEST_TMP_DIR, { recursive: true }), but createTestConfigDir() later calls mkdtemp(join(TEST_TMP_DIR, prefix)) without recreating/checking the parent. Therefore, if another preload invocation removes the shared worker root after module initialization, subsequent createTestConfigDir() calls can fail with ENOENT.VITEST_POOL_ID use the same TEST_TMP_DIR, while each preload.ts execution wipes that entire root rather than only its own preload-${process.pid} child; this can delete directories belonging to other files in the same worker and explains both missing DSN scan files and mkdtemp failures.useTestConfigDir() teardown rule: βAlways restore the previous value β never delete.βpreload.ts always sets SENTRY_CONFIG_DIR.savedConfigDir is always defined in practice.useTestConfigDir() in packages/cli/test/helpers.ts saves process.env[CONFIG_DIR_ENV_VAR] during beforeEach, closes the database, resets resetAuthTokenCache(), resetAuthRowCache(), resetHasStoredCredsCache(), and resetIdentityFingerprintCache(), creates a fresh config directory, and points the config environment variable to it.useTestConfigDir() teardown repeats database/cache cleanup, restores process.env[CONFIG_DIR_ENV_VAR] only when savedConfigDir !== undefined, and then calls cleanupTestDir(dir); the intentionally omitted delete branch prevents later-loading test files from observing an undefined SENTRY_CONFIG_DIR.useTestConfigDir(), create the project directory beneath join(getConfigDir(), "project"), clear process.env.SENTRY_DSN, and include monorepo/deduplication coverage. This confirms the failed DSN test depends on the shared helperβs temp-root lifecycle rather than independently creating the missing root.