Skip to content

Commit b608933

Browse files
authored
Update limits.mdx
add new FAQ on how to handle 429 rate limits with retry after header
1 parent 3ba94da commit b608933

File tree

1 file changed

+65
-4
lines changed
  • src/content/docs/browser-rendering/platform

1 file changed

+65
-4
lines changed

src/content/docs/browser-rendering/platform/limits.mdx

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ While the limits above define the maximum number of concurrent browser sessions
5555

5656
## FAQ
5757

58-
### I upgraded from the Workers Free plan, but I'm still hitting the 10-minute per day limit. What should I do?
59-
60-
If you recently upgraded to the [Workers Paid plan](/workers/platform/pricing/) but still encounter the 10-minute per day limit, redeploy your Worker to ensure your usage is correctly associated with the new plan.
61-
6258
<Render
6359
file="manage-concurrency-faq"
6460
product="browser-rendering"
@@ -72,4 +68,69 @@ By default, a browser instance will time out after 60 seconds of inactivity. If
7268

7369
There is no fixed maximum lifetime for a browser session as long as it remains active. By default, a browser will close after one minute of inactivity, but you can [extend this inactivity window](#can-i-increase-the-browser-timeout). Sessions will also be closed when Browser Rendering rolls out a new release.
7470

71+
### I see `429 Too Many Requests`. How do I fix it?
72+
73+
When you make too many requests in a short period of time, Browser Rendering will respond with HTTP status code `429 Too Many Requests`.
74+
The response includes a `Retry-After` header, which specifies how many seconds to wait before retrying. You can view your account's rate limits on the [Limits](/browser-rendering/platform/limits/) page.
75+
76+
The example below demonstrates how to handle rate limiting gracefully by reading the `Retry-After` value and retrying the request after that delay.
77+
78+
<Tabs syncKey="workersExamples"> <TabItem label="REST API">
79+
```js
80+
const response = await fetch('https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content', {
81+
method: 'POST',
82+
headers: {
83+
'Content-Type': 'application/json',
84+
'Authorization': 'Bearer <your-token>',
85+
},
86+
body: JSON.stringify({ url: 'https://example.com' })
87+
});
88+
89+
if (response.status === 429) {
90+
const retryAfter = response.headers.get('Retry-After');
91+
console.log(`Rate limited. Waiting ${retryAfter} seconds...`);
92+
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
93+
94+
// Retry the request
95+
const retryResponse = await fetch(/* same request as above */);
96+
}
97+
```
98+
99+
</TabItem> <TabItem label="Workers Bindings">
100+
101+
```js
102+
import puppeteer from "@cloudflare/puppeteer";
75103

104+
try {
105+
const browser = await puppeteer.launch(env.MYBROWSER);
106+
107+
const page = await browser.newPage();
108+
await page.goto("https://example.com");
109+
const content = await page.content();
110+
111+
await browser.close();
112+
} catch (error) {
113+
if (error.status === 429) {
114+
const retryAfter = error.headers.get("Retry-After");
115+
console.log(
116+
`Browser instance limit reached. Waiting ${retryAfter} seconds...`,
117+
);
118+
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
119+
120+
// Retry launching browser
121+
const browser = await puppeteer.launch(env.MYBROWSER);
122+
}
123+
}
124+
```
125+
126+
</TabItem> </Tabs>
127+
128+
### I see `Error processing the request: Unable to create new browser: code: 429: message: Browser time limit exceeded for today`. How do I fix it?
129+
130+
This error indicates you have hit the daily browser-instance limit on the Workers Free plan. [Free-plan accounts are capped at free plan limit is 10 minutes of browser use a day](/browser-rendering/platform/limits/#workers-free) once you exceed those, further creation attempts return a 429 until the next UTC day.
131+
132+
To resolve: [Upgrade to a Workers Paid plan](/workers/platform/pricing/) which allows for more than 10 minutes of usage a day and has higher [limits](/browser-rendering/platform/limits/#workers-paid). If you recently upgraded but still see this error, try redeploying your Worker to ensure your usage is correctly associated with your new plan.
133+
134+
### I upgraded from the Workers Free plan, but I'm still hitting the 10-minute per day limit. What should I do?
135+
136+
If you recently upgraded to the [Workers Paid plan](/workers/platform/pricing/) but still encounter the 10-minute per day limit, redeploy your Worker to ensure your usage is correctly associated with the new plan.

0 commit comments

Comments
 (0)