How do you handle long work that continues after the HTTP request ends?
Answer out loud or in your head first, then compare.
Answer
If the result matters, I don't just run a function in the background and hope the server lives long enough. I create a job with an ID and a status, and hand the execution to a durable queue. The client gets told how to read the result later.
The program that runs the job records success or failure. If it stops, the system should be able to resume the work. That's different behaviour from void doWork() without handling or recording. In a short script such a shortcut is sometimes enough, but it doesn't give durable handling of a business task. An error after the response has been sent can no longer simply be added to that HTTP response.
Why it matters: The basis of document processing and long-running agent actions.
Possible follow-ups: Where will the user see the error? How do you spot a job abandoned after a crash?
How did it go? Be honest — “Not yet” puts the question on your review list.
Start with
- B-P01 · What is Node.js, and how is it different from JavaScript in the browser? — JavaScript, TypeScript and Node.js
- B-P04 · What is a Promise? — JavaScript, TypeScript and Node.js
- B-P10 · What does TypeScript give you, and what doesn't it? — JavaScript, TypeScript and Node.js
Further reading
- Node.js: The Event Loop(opens in a new tab)Docs; accessed 22.10.2026. Event loop phases, timers and differences between Node/libuv versions.