Asynchronous and Event-Driven Programming Questions

The programming model of a single asynchronous runtime: callbacks, promises and futures, async/await, event loops and task/microtask scheduling (including microtask starvation and where rendering fits), reactive streams and back-pressure, and how ordering, cancellation, timeouts, retries and error propagation behave across JavaScript, Node.js, mobile coroutine or async runtimes, and a comparison with Python asyncio and Java futures. Includes the async mechanics of a data fetch such as parallel versus sequential requests, partial failure, stale or out-of-order responses, abort, debounced live search, single-flight token refresh, and bounded concurrency; wrapping callback APIs as promises, streaming work through async consumers, moving heavy work off the main thread and back, and diagnosing unhandled rejections, race conditions and leaked subscriptions. Excludes message-queue and pub/sub system design, server throughput and thread-pool tuning, per-language threading and memory models, rebuilding standard APIs from scratch, and fetch caching or state architecture.

MediumTechnical
59 practiced

A page freezes and stops painting even though no single function looks slow: a long promise chain keeps scheduling more promise work. Explain why timers and rendering never get a turn, show code that causes it, and how you would restructure it so the page stays responsive.

MediumTechnical
52 practiced

Users rapidly click different items and occasionally the detail panel ends up showing the wrong item. Review the code below, explain exactly how that happens, and fix it so only the response for the most recent click is ever rendered.

js
let current = {};
function fetchAndSet(id) {
  fetch(`/data/${id}`).then(res => res.json()).then(data => { current = data; render(current); });
}
MediumTechnical
56 practiced

Users report intermittent out-of-order updates in a production app that you cannot reproduce locally. How do you find out whether async responses are being applied out of order, what would you instrument and how do you keep the data volume sane, and how would you turn the finding into a reliable test?

MediumTechnical
55 practiced

You have an array of functions that each return a promise, for example 500 uploads. Write runWithConcurrency(tasks, limit) that keeps at most limit running at once, returns results in the original order, and lets the caller choose between stopping at the first failure and collecting every outcome. How does it behave when limit exceeds the task count or a task throws synchronously?

EasyTechnical
49 practiced

What is a promise and what states can it be in? Walk through what happens when you attach a handler before it settles and after it settles, why a handler never runs synchronously, and what a thenable is.

Unlock Full Question Bank

Get access to all 23 Asynchronous and Event-Driven Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.