The Short Answer
Deregister long-running tasks from the request thread, persist their progress, and notify the client asynchronously via webhooks or event streams. Never hold a single JSON-RPC call open for minutes.
Expose a task/<id> resource so clients can poll status, and emit notifications/message events as progress updates arrive.
Pro Tip: Idempotent Retries
Make every background action idempotent so a retried request can't double-charge or double-insert.