r/programming • • 14d ago

What Happens to Work After a Timeout?

https://octri.dev/blog/what-happens-to-work-after-a-timeout
21 Upvotes

4 comments sorted by

2

u/tanyadev4827 14d ago

Interesting

2

u/robert_7524 14d ago

Does the timeout cancel the underlying operation, or only stop the caller from waiting? That distinction determines whether work can keep running after the timeout.

5

u/elmuerte 14d ago

Rarely does a timeout immediately cancel the work on the client.

Look at it like this: somebody asks you to find a book based library, so you are out fetching it. After 5 minutes you return, the person is gone (timed out). The person left after waiting 3 minutes.

In some rare cases you can communicate the timeout to the operation. "Find me a book unless it takes more than 3 minutes". Then the operation needs to regularly check if it is working for more than 3 minutes.

The shit part usually is, that after a timeout was reached, the client will just retry the same operation. Unless you cached (part) of your work, you are wasting quite a bit of effort.

2

u/ava_896517 13d ago

For side-effecting work, retries need deduplication (often an idempotency key), or the same action may happen twice.