Skip to content

Commit 1e2b464

Browse files
authored
feat(debug): when debugging, use zero as default timeout (#2362)
Otherwise, operations always time out while stepping in debugger.
1 parent 37ec3a6 commit 1e2b464

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/server/browserType.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export abstract class BrowserTypeBase implements BrowserType {
112112
}
113113

114114
async _innerLaunch(options: LaunchOptions, persistent: PersistentContextOptions | undefined, userDataDir?: string): Promise<BrowserBase> {
115-
const deadline = TimeoutSettings.computeDeadline(options.timeout, 30000);
115+
const deadline = TimeoutSettings.computeDeadline(options.timeout);
116116
const logger = new RootLogger(options.logger);
117117
logger.startLaunchRecording();
118118

@@ -159,13 +159,13 @@ export abstract class BrowserTypeBase implements BrowserType {
159159
assert(!(options as any).userDataDir, 'userDataDir option is not supported in `browserType.launchServer`. Use `browserType.launchPersistentContext` instead');
160160
const { port = 0 } = options;
161161
const logger = new RootLogger(options.logger);
162-
const { browserServer, transport } = await this._launchServer(options, false, logger, TimeoutSettings.computeDeadline(options.timeout, 30000));
162+
const { browserServer, transport } = await this._launchServer(options, false, logger, TimeoutSettings.computeDeadline(options.timeout));
163163
browserServer._webSocketWrapper = this._wrapTransportWithWebSocket(transport, logger, port);
164164
return browserServer;
165165
}
166166

167167
async connect(options: ConnectOptions): Promise<Browser> {
168-
const deadline = TimeoutSettings.computeDeadline(options.timeout, 30000);
168+
const deadline = TimeoutSettings.computeDeadline(options.timeout);
169169
const logger = new RootLogger(options.logger);
170170
logger.startLaunchRecording();
171171

src/server/electron.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class Electron {
168168
handleSIGTERM = true,
169169
handleSIGHUP = true,
170170
} = options;
171-
const deadline = TimeoutSettings.computeDeadline(options.timeout, 30000);
171+
const deadline = TimeoutSettings.computeDeadline(options.timeout);
172172
let app: ElectronApplication | undefined = undefined;
173173

174174
const logger = new RootLogger(options.logger);

src/timeoutSettings.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
import { TimeoutOptions } from './types';
1919
import { helper } from './helper';
20+
import * as debugSupport from './debug/debugSupport';
2021

21-
const DEFAULT_TIMEOUT = 30000;
22+
const DEFAULT_TIMEOUT = debugSupport.isDebugMode() ? 0 : 30000;
2223

2324
export class TimeoutSettings {
2425
private _parent: TimeoutSettings | undefined;
@@ -55,16 +56,13 @@ export class TimeoutSettings {
5556
return DEFAULT_TIMEOUT;
5657
}
5758

58-
computeDeadline(options?: TimeoutOptions) {
59-
const { timeout } = options || {};
60-
return TimeoutSettings.computeDeadline(typeof timeout === 'number' ? timeout : this._timeout());
59+
computeDeadline(options: TimeoutOptions = {}) {
60+
return TimeoutSettings.computeDeadline(options.timeout, this._timeout());
6161
}
6262

63-
static computeDeadline(timeout: number | undefined, defaultValue = 30000): number {
64-
if (timeout === 0)
65-
return Number.MAX_SAFE_INTEGER;
66-
else if (typeof timeout === 'number')
67-
return helper.monotonicTime() + timeout;
68-
return helper.monotonicTime() + defaultValue;
63+
static computeDeadline(timeout: number | undefined, defaultValue = DEFAULT_TIMEOUT): number {
64+
if (typeof timeout !== 'number')
65+
timeout = defaultValue;
66+
return timeout ? helper.monotonicTime() + timeout : Number.MAX_SAFE_INTEGER;
6967
}
7068
}

0 commit comments

Comments
 (0)