feat(debug): when debugging, use zero as default timeout (#2362)
Otherwise, operations always time out while stepping in debugger.
This commit is contained in:
parent
37ec3a6ae6
commit
1e2b46437d
|
|
@ -112,7 +112,7 @@ export abstract class BrowserTypeBase implements BrowserType {
|
|||
}
|
||||
|
||||
async _innerLaunch(options: LaunchOptions, persistent: PersistentContextOptions | undefined, userDataDir?: string): Promise<BrowserBase> {
|
||||
const deadline = TimeoutSettings.computeDeadline(options.timeout, 30000);
|
||||
const deadline = TimeoutSettings.computeDeadline(options.timeout);
|
||||
const logger = new RootLogger(options.logger);
|
||||
logger.startLaunchRecording();
|
||||
|
||||
|
|
@ -159,13 +159,13 @@ export abstract class BrowserTypeBase implements BrowserType {
|
|||
assert(!(options as any).userDataDir, 'userDataDir option is not supported in `browserType.launchServer`. Use `browserType.launchPersistentContext` instead');
|
||||
const { port = 0 } = options;
|
||||
const logger = new RootLogger(options.logger);
|
||||
const { browserServer, transport } = await this._launchServer(options, false, logger, TimeoutSettings.computeDeadline(options.timeout, 30000));
|
||||
const { browserServer, transport } = await this._launchServer(options, false, logger, TimeoutSettings.computeDeadline(options.timeout));
|
||||
browserServer._webSocketWrapper = this._wrapTransportWithWebSocket(transport, logger, port);
|
||||
return browserServer;
|
||||
}
|
||||
|
||||
async connect(options: ConnectOptions): Promise<Browser> {
|
||||
const deadline = TimeoutSettings.computeDeadline(options.timeout, 30000);
|
||||
const deadline = TimeoutSettings.computeDeadline(options.timeout);
|
||||
const logger = new RootLogger(options.logger);
|
||||
logger.startLaunchRecording();
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ export class Electron {
|
|||
handleSIGTERM = true,
|
||||
handleSIGHUP = true,
|
||||
} = options;
|
||||
const deadline = TimeoutSettings.computeDeadline(options.timeout, 30000);
|
||||
const deadline = TimeoutSettings.computeDeadline(options.timeout);
|
||||
let app: ElectronApplication | undefined = undefined;
|
||||
|
||||
const logger = new RootLogger(options.logger);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
import { TimeoutOptions } from './types';
|
||||
import { helper } from './helper';
|
||||
import * as debugSupport from './debug/debugSupport';
|
||||
|
||||
const DEFAULT_TIMEOUT = 30000;
|
||||
const DEFAULT_TIMEOUT = debugSupport.isDebugMode() ? 0 : 30000;
|
||||
|
||||
export class TimeoutSettings {
|
||||
private _parent: TimeoutSettings | undefined;
|
||||
|
|
@ -55,16 +56,13 @@ export class TimeoutSettings {
|
|||
return DEFAULT_TIMEOUT;
|
||||
}
|
||||
|
||||
computeDeadline(options?: TimeoutOptions) {
|
||||
const { timeout } = options || {};
|
||||
return TimeoutSettings.computeDeadline(typeof timeout === 'number' ? timeout : this._timeout());
|
||||
computeDeadline(options: TimeoutOptions = {}) {
|
||||
return TimeoutSettings.computeDeadline(options.timeout, this._timeout());
|
||||
}
|
||||
|
||||
static computeDeadline(timeout: number | undefined, defaultValue = 30000): number {
|
||||
if (timeout === 0)
|
||||
return Number.MAX_SAFE_INTEGER;
|
||||
else if (typeof timeout === 'number')
|
||||
return helper.monotonicTime() + timeout;
|
||||
return helper.monotonicTime() + defaultValue;
|
||||
static computeDeadline(timeout: number | undefined, defaultValue = DEFAULT_TIMEOUT): number {
|
||||
if (typeof timeout !== 'number')
|
||||
timeout = defaultValue;
|
||||
return timeout ? helper.monotonicTime() + timeout : Number.MAX_SAFE_INTEGER;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue