Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure there is a check for targets when timeout=0 #8765

Merged
merged 1 commit into from Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/Browser.ts
Expand Up @@ -649,10 +649,10 @@ export class Browser extends EventEmitter {
this.on(BrowserEmittedEvents.TargetCreated, check);
this.on(BrowserEmittedEvents.TargetChanged, check);
try {
this.targets().forEach(check);
if (!timeout) {
return await targetPromise;
}
this.targets().forEach(check);
return await waitWithTimeout(targetPromise, 'target', timeout);
} finally {
this.off(BrowserEmittedEvents.TargetCreated, check);
Expand Down
8 changes: 8 additions & 0 deletions test/src/launcher.spec.ts
Expand Up @@ -543,6 +543,14 @@ describe('Launcher specs', function () {
});
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should work with timeout = 0', async () => {
const {puppeteer, defaultBrowserOptions} = getTestState();
const options = Object.assign({}, defaultBrowserOptions, {
timeout: 0,
});
const browser = await puppeteer.launch(options);
await browser.close();
});
it('should set the default viewport', async () => {
const {puppeteer, defaultBrowserOptions} = getTestState();
const options = Object.assign({}, defaultBrowserOptions, {
Expand Down