COMPUTER ENGINEER

Jump to examples
Blog
HTTP / HTTPS / TLS6 min study
60/ 70

Reliability and error handling

Long-running jobs: 202, job resources and cancellation

Design the job lifecycle instead of merely increasing timeouts.

UnderstandStudy an examplePractise

Understand the concept

Video processing or CV analysis can outlast a request. 202 means accepted, not completed or guaranteed to succeed. Expose a job resource with application states such as pending, running, succeeded, failed and cancelled. These are application states rather than replacements for HTTP status semantics.

Poll the status resource at a controlled pace using the documented contract. A completed job can provide a result representation or a separate result address. Protect jobs and results with ownership and tenant checks, and return safe error information.

A timeout does not prove that nothing was queued. Handle repeated submissions with idempotency. Cancellation can be best-effort after irreversible work. Closing a browser tab does not automatically cancel backend work. Queue capacity, retention, retries and restart behaviour are part of the operational design.

WHEN TO USE IT

For AI analysis, video processing and exports.

COMMON PITFALL

Assuming AbortController guarantees cancellation of backend work.

01 / PRACTICE

One topic. Three levels of depth.

HTTP / illustrative example
HTTP/1.1 202 Accepted
Location: /jobs/42

The application’s monitoring address, not a completion guarantee.

This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.

02 / YOUR TURN

Try it yourself first.

Does closing the tab automatically stop the job?

Show the solution and explanation
Worked solution
No: cancellation needs an explicit backend contract.

No. An explicit cancellation contract and worker behaviour are needed.