Skip to content

Commit 018a0b0

Browse files
authored
Add clearer note about the need to recreate DO stubs after exceptions (#25459)
1 parent dcb9469 commit 018a0b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/content/docs/durable-objects/best-practices/error-handling.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import { GlossaryTooltip } from "~/components";
99

1010
Any uncaught exceptions thrown by a <GlossaryTooltip term="Durable Object">Durable Object</GlossaryTooltip> or thrown by Durable Objects' infrastructure (such as overloads or network errors) will be propagated to the callsite of the client. Catching these exceptions allows you to retry creating the [`DurableObjectStub`](/durable-objects/api/stub) and sending requests.
1111

12-
JavaScript Errors with the property `.retryable` set to True are suggested to be retried if requests to the Durable Object are idempotent, or can be applied multiple times without changing the response. If requests are not idempotent, then you will need to decide what is best for your application.
12+
JavaScript Errors with the property `.retryable` set to True are suggested to be retried if requests to the Durable Object are idempotent, or can be applied multiple times without changing the response. If requests are not idempotent, then you will need to decide what is best for your application. It is strongly recommended to apply exponential backoff when retrying requests.
1313

1414
JavaScript Errors with the property `.overloaded` set to True should not be retried. If a Durable Object is overloaded, then retrying will worsen the overload and increase the overall error rate.
1515

16-
It is strongly recommended to retry requests following the exponential backoff algorithm in production code when the error properties indicate that it is safe to do so.
16+
:::note[Recreating the DurableObjectStub after exceptions]
17+
18+
Many exceptions leave the [`DurableObjectStub`](/durable-objects/api/stub) in a "broken" state, such that all attempts to send additional requests will just fail immediately with the original exception. To avoid this, you should avoid reusing a `DurableObjectStub` after it throws an exception. You should instead create a new one for any subsequent requests.
19+
20+
:::
1721

1822
## How exceptions are thrown
1923

0 commit comments

Comments
 (0)