-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Allow options.timeout to be 0
to disable timeout
#887
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,12 @@ class NavigatorWatcher { | |
|
||
this._eventListeners = []; | ||
|
||
const watchdog = new Promise(fulfill => this._maximumTimer = setTimeout(fulfill, this._timeout)) | ||
.then(() => 'Navigation Timeout Exceeded: ' + this._timeout + 'ms exceeded'); | ||
const navigationPromises = [watchdog]; | ||
const navigationPromises = []; | ||
if (this._timeout) { | ||
const watchdog = new Promise(fulfill => this._maximumTimer = setTimeout(fulfill, this._timeout)) | ||
.then(() => 'Navigation Timeout Exceeded: ' + this._timeout + 'ms exceeded'); | ||
navigationPromises.push(watchdog); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is as the @aslushnikov suggestion, it's simple and clear code. But it think it still have problem if user pass timeout 0 as a string. I'd like add more conditional check, or we just rely on the documentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brutalcrozt yes, we should rely on documentation in this case and expect user to pass in a number. There's also a check that timeout is always a number: https://github.com/GoogleChrome/puppeteer/blob/c46c41d89caefd1e1951055fb041521a2bcc933b/lib/NavigatorWatcher.js#L28 |
||
|
||
if (!this._ignoreHTTPSErrors) { | ||
const certificateError = new Promise(fulfill => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -619,6 +619,14 @@ describe('Page', function() { | |
expect(error.message).toContain('Navigation Timeout Exceeded: 1ms'); | ||
process.removeListener('unhandledRejection', unhandledRejectionHandler); | ||
})); | ||
it('should disable timeout when its set to 0', SX(async function() { | ||
server.setRoute('/empty.html', (req, res) => {}); | ||
let error = null; | ||
page.goto(PREFIX + '/empty.html', {timeout: 0}).catch(e => error = e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
await page.goto(PREFIX + '/empty.html', {timeout: 0}).catch(e => error = e); |
||
// const sleep = e => new Promise(ff => setTimeout(ff, e)); | ||
// await sleep(90000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
agree, sorry but leave it as comment. Perhaps someone want to inspect this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, drop these comments: they are not useful for other puppeteer developers. |
||
expect(error).toBe(null); | ||
}));// 100000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please drop the comment here as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok sir |
||
it('should work when navigating to valid url', SX(async function() { | ||
const response = await page.goto(EMPTY_PAGE); | ||
expect(response.ok).toBe(true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bunch of other methods that rely on NavigationWatcher, so you should add this clarification there as well: