|
| 1 | +--- |
| 2 | +pcx_content_type: reference |
| 3 | +title: REST API timeouts |
| 4 | +sidebar: |
| 5 | + order: 5 |
| 6 | +--- |
| 7 | +import { Tabs, TabItem } from "~/components"; |
| 8 | + |
| 9 | +Browser Rendering uses several independent timers to manage how long different parts of a request can take. |
| 10 | +If any of these timers exceed their limit, the request returns a timeout error. |
| 11 | + |
| 12 | +Each timer controls a specific part of the rendering lifecycle — from page load, to selector load, to action. |
| 13 | + |
| 14 | +| Timer | Scope |Default |Max | |
| 15 | +| -------------------------------------- | --------------- | --------------- | --------------- | |
| 16 | +| `goToOptions.timeout` | Time to wait for the page to load before timeout. | 30 s | 60 s | |
| 17 | +| `goToOptions.waitUntil` | Time until page load considered complete: <br />`load` = full page load, including resources, like images and stylesheets. <br />`Event.domcontentloaded` = waits until the DOM content has been fully loaded, fires before the page `load` event. <br />`Event.networkidle0` = there are no active network connections for at least 500 ms. <br />`Event.networkidle2` = there are no more than two active network connections for at least 500 ms. | — | — | |
| 18 | +| `waitForSelector` | Time to wait for a specific element (any CSS selector) to appear on the page. | null | 60 s | |
| 19 | +| `waitForTimeout` | Additional amount of time to wait after the page has loaded to proceed with actions. | null | 60 s | |
| 20 | +| `actionTimeout` | Time to wait for the action itself (for example: a screenshot, PDF, or scrape) to complete after the page has loaded. | null | 5 min | |
| 21 | +| `PDFOptions.timeout` | Same as `actionTimeout`, but only applies to the [/pdf endpoint](/browser-rendering/rest-api/pdf-endpoint/). | 30 s | 5 min | |
| 22 | + |
| 23 | +## Notes and recommendations |
| 24 | +You can set multiple timers — as long as one is complete, the request will fire. |
| 25 | + |
| 26 | +If you are not getting the expected output: |
| 27 | +- Try increasing `goToOptions.timeout` (up to 60 s). |
| 28 | +- If waiting for a specific element, use `waitForSelector`. Otherwise, use `goToOptions.waitUntil` set to `networkidle2` to ensure the page has finished loading dynamic content. |
| 29 | +- If you are getting a `422`, it may be the action itself (ex: taking a screenshot, extracting the html content) that takes a long time. Try increasing the `actionTimeout` instead. |
0 commit comments