Your job takes 20 minutes. The gateway gives up at 60 seconds.
transcript
A partner asks you to regenerate every product image. It takes up to 20 minutes. Your gateway waits 60 seconds. Then 504. So they call again.
Slow work can't live inside a request. Gateways and networks drop it. And every retry starts the whole job again.
The fix: make the work a resource. Answer at once: 202 Accepted. Not finished, but accepted. No one holds a connection. Plus a status URL. The client polls it. Running. Still running. Done? The status hands back a link to the result.
Polling works anywhere. But it wastes calls on a 20 minute job. So send a signed webhook when it's done. Keep the status URL for missed ones.
But here's the catch. Their script crashes, and calls again. The call carries the same idempotency key. So it gets the same operation back. No second job.
Don't make anyone hold a connection for 20 minutes. Accept now. Report progress. Finish later.
Full breakdown in the lecture.