Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: avoid using `os.userInfo()` (#22826)
Andrey Lushnikov3b2d247c74ed
diff --git a/packages/playwright-test/src/common/compilationCache.ts b/packages/playwright-test/src/common/compilationCache.tsindex 9f32bba821..0e6e3cf6cc 100644--- a/packages/playwright-test/src/common/compilationCache.ts+++ b/packages/playwright-test/src/common/compilationCache.ts@@ -19,7 +19,6 @@ import fs from 'fs';import os from 'os';import path from 'path';import { sourceMapSupport } from '../utilsBundle';-import { sanitizeForFilePath } from '../util';export type MemoryCache = {codePath: string;@@ -29,10 +28,15 @@ export type MemoryCache = {const version = 13;-const DEFAULT_CACHE_DIR_WIN32 = path.join(os.tmpdir(), `playwright-transform-cache`);-const DEFAULT_CACHE_DIR_POSIX = path.join(os.tmpdir(), `playwright-transform-cache-` + sanitizeForFilePath(os.userInfo().username));--const cacheDir = process.env.PWTEST_CACHE_DIR || (process.platform === 'win32' ? DEFAULT_CACHE_DIR_WIN32 : DEFAULT_CACHE_DIR_POSIX);+const cacheDir = process.env.PWTEST_CACHE_DIR || (() => {+ if (process.platform === 'win32')+ return path.join(os.tmpdir(), `playwright-transform-cache`);+ // Use `geteuid()` instead of more natural `os.userInfo().username`+ // since `os.userInfo()` is not always available.+ // Note: `process.geteuid()` is not available on windows.+ // See https://github.com/microsoft/playwright/issues/22721+ return path.join(os.tmpdir(), `playwright-transform-cache-` + process.geteuid());+})();const sourceMaps: Map<string, string> = new Map();const memoryCache = new Map<string, MemoryCache>();