diff --git a/packages/playwright-core/src/server/browserType.ts b/packages/playwright-core/src/server/browserType.ts index 69cb412f1d..d900b792cc 100644 --- a/packages/playwright-core/src/server/browserType.ts +++ b/packages/playwright-core/src/server/browserType.ts @@ -31,8 +31,6 @@ import { helper } from './helper'; import { RecentLogsCollector } from '../utils/debugLogger'; import { CallMetadata, SdkObject } from './instrumentation'; -const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-'); - export abstract class BrowserType extends SdkObject { private _name: BrowserName; readonly _playwrightOptions: PlaywrightOptions; @@ -143,7 +141,7 @@ export abstract class BrowserType extends SdkObject { if (options.tracesDir) await fs.promises.mkdir(options.tracesDir, { recursive: true }); - const artifactsDir = await fs.promises.mkdtemp(ARTIFACTS_FOLDER); + const artifactsDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-artifacts-')); tempDirectories.push(artifactsDir); if (userDataDir) { diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.ts index bf54dd099c..5743a9c6b3 100644 --- a/packages/playwright-core/src/server/trace/recorder/tracing.ts +++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts @@ -16,7 +16,7 @@ import { EventEmitter } from 'events'; import fs from 'fs'; -import { APIRequestContext } from '../../fetch'; +import os from 'os'; import path from 'path'; import yazl from 'yazl'; import { NameValue } from '../../../common/types'; @@ -27,6 +27,7 @@ import { assert, calculateSha1, createGuid, mkdirIfNeeded, monotonicTime, remove import { Artifact } from '../../artifact'; import { BrowserContext } from '../../browserContext'; import { ElementHandle } from '../../dom'; +import { APIRequestContext } from '../../fetch'; import { CallMetadata, InstrumentationListener, SdkObject } from '../../instrumentation'; import { Page } from '../../page'; import * as har from '../../supplements/har/har'; @@ -192,7 +193,7 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps private async _createTracesDirIfNeeded() { if (this._precreatedTracesDir) return this._precreatedTracesDir; - this._tracesTmpDir = await fs.promises.mkdtemp('playwright-tracing-'); + this._tracesTmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-tracing-')); return this._tracesTmpDir; }