Skip to content

Commit c0507fb

Browse files
committed
Adding some docs about the request options
1 parent 3f56fa7 commit c0507fb

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.changeset/lemon-sloths-hide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
"@trigger.dev/core": patch
4+
---
5+
6+
v3: recover from server rate limiting errors in a more reliable way

docs/v3/management/overview.mdx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,47 @@ async function main() {
161161
}
162162
```
163163

164+
## Retries
165+
166+
The SDK will automatically retry requests that fail due to network errors or server errors. By default, the SDK will retry requests up to 3 times, with an exponential backoff delay between retries.
167+
168+
You can customize the retry behavior by passing a `requestOptions` option to the `configure` function:
169+
170+
```ts
171+
import { configure } from "@trigger.dev/sdk/v3";
172+
173+
configure({
174+
requestOptions: {
175+
retry: {
176+
maxAttempts: 5,
177+
minTimeoutInMs: 1000,
178+
maxTimeoutInMs: 5000,
179+
factor: 1.8,
180+
randomize: true,
181+
},
182+
},
183+
});
184+
```
185+
186+
All SDK functions also take a `requestOptions` parameter as the last argument, which can be used to customize the request options. You can use this to disable retries for a specific request:
187+
188+
```ts
189+
import { runs } from "@trigger.dev/sdk/v3";
190+
191+
async function main() {
192+
const run = await runs.retrieve("run_1234", {
193+
retry: {
194+
maxAttempts: 1, // Disable retries
195+
},
196+
});
197+
}
198+
```
199+
200+
<Note>
201+
When running inside a task, the SDK ignores customized retry options for certain functions (e.g.,
202+
`task.trigger`, `task.batchTrigger`), and uses retry settings optimized for task execution.
203+
</Note>
204+
164205
## Auto-pagination
165206

166207
All list endpoints in the management API support auto-pagination.

0 commit comments

Comments
 (0)