Skip to main content

Find Cases

Find the exact JavaScript confusion you are trying to solve.

Search by symptom, topic, difficulty, or real-world problem across guided demos, editable variations, and Node runtime cases.

98 matching cases
Guided - Event Loop

Sync execution

Synchronous lines run immediately, top to bottom.

Real use: Most setup code, imports, and simple calculations behave this way.
Open case
Guided - Event Loop

setTimeout 0

A zero millisecond timer still waits for the stack to clear.

Real use: Useful when you need to defer UI work until after the current event handler.
Open case
Guided - Event Loop

Promise before timeout

Microtasks run before timers after the stack clears.

Real use: Promise-based state updates can happen before scheduled timers and animation cleanup.
Open case
Guided - Event Loop

Multiple timers

Timers with the same delay run in the order they were queued.

Real use: Timer order matters in tests, retries, and UI scheduling.
Open case
Guided - Event Loop

Nested timeout

A timer created inside a timer waits for another task turn.

Real use: Nested timers are common in retry loops and staged UI updates.
Open case
Guided - Event Loop

Promise inside timeout

Microtasks created by a timer run before the next timer.

Real use: This affects promise work triggered inside DOM events, timers, and network callbacks.
Open case
Guided - Event Loop

Timeout inside promise

A timer created by a microtask joins the timer queue after existing timers.

Real use: This shows up in promise-based setup that schedules fallback timers.
Open case
Guided - Event Loop

Blocking loop

Long synchronous work delays every queued callback.

Real use: Blocking work freezes clicks, rendering, and input handling.
Open case
Guided - Promises

Promise lifecycle

A promise starts pending, then settles once.

Real use: Promise wrappers often do setup immediately, even before any `.then` callback.
Open case
Guided - Promises

Promise rejection

Rejected promises skip success handlers and go to rejection handlers.

Real use: Centralized `.catch` handlers are common for fetch and async workflows.
Open case
Guided - Promises

then chaining

Returning a value passes it to the next `.then`.

Real use: Data pipelines often parse, map, and render through promise chains.
Open case
Guided - Promises

Missing return

If a `.then` callback does not return, the next value is `undefined`.

Real use: Missing returns commonly break request chains and test setup.
Open case
Guided - Promises

Error in then

Throwing inside `.then` turns the next promise into a rejection.

Real use: This is why `.catch` can handle JSON parsing or mapping failures after fetch.
Open case
Guided - Promises

Promise.all success

`Promise.all` resolves when every input resolves.

Real use: Use it when independent requests must all finish before rendering.
Open case
Guided - Promises

Promise.all fail

`Promise.all` rejects as soon as one input rejects.

Real use: Use `Promise.allSettled` when you need every result, including failures.
Open case
Guided - Async/Await

async returns promise

An async function always returns a promise.

Real use: Callers must `await` or `.then` async function results.
Open case
Guided - Async/Await

await behavior

`await` pauses the async function and resumes it in a microtask.

Real use: Await points can let other code observe intermediate state.
Open case
Guided - Async/Await

missing await

Without `await`, code keeps going while the promise is pending.

Real use: Missing awaits can cause loading states, redirects, or assertions to run too early.
Open case
Guided - Async/Await

try/catch

A try/catch around `await` catches promise rejections.

Real use: This is the normal shape for request error handling in async functions.
Open case
Guided - Async/Await

sequential await

Awaiting one operation before starting the next makes them sequential.

Real use: Sequential awaits are correct for dependencies but slow for independent API calls.
Open case
Guided - Async/Await

parallel Promise.all

Start independent promises first, then await them together.

Real use: This pattern reduces latency for independent dashboard or page data.
Open case
Guided - Async/Await

async forEach issue

`forEach` does not await async callbacks.

Real use: Use `for...of` for sequential work or `Promise.all(items.map(...))` for parallel work.
Open case
Guided - Memory

interval leak

Intervals keep callbacks and captured data alive until cleared.

Real use: Clear polling intervals in React effects, widgets, and background refresh loops.
Open case
Guided - Memory

event listener leak

Listeners can retain component state after the UI is gone.

Real use: Clean up window, document, and shared element listeners in component lifecycles.
Open case
Guided - Memory

closure memory hold

Closures keep referenced outer variables alive.

Real use: Closures are useful for caches and private state, but can accidentally retain large objects.
Open case
Guided - Memory

cache growth

Caches need eviction or they grow for the lifetime of the app.

Real use: Use LRU, TTL, explicit invalidation, or WeakMap when appropriate.
Open case
Guided - Performance

blocking loop

CPU-heavy loops monopolize the main thread.

Real use: Chunk work, use Web Workers, or move heavy calculations off the main thread.
Open case
Guided - Performance

microtask flood

Too many microtasks can starve timers and rendering.

Real use: Long microtask chains can delay rendering, timers, and input responsiveness.
Open case
Guided - Performance

sequential vs parallel API

Independent API calls are faster when started together.

Real use: Dashboards, profile pages, and search screens often benefit from parallel loading.
Open case
Guided - Performance

debounce concept

Debounce resets a timer so only the final burst action runs.

Real use: Autocomplete, resize handlers, and validation often use debounce.
Open case
Guided - Node.js Runtime

process.nextTick vs Promise

In Node.js, nextTick callbacks run before Promise microtasks.

Real use: This matters in Node libraries, stream internals, CLIs, and tests that mix nextTick with promises.
Open case
Guided - Node.js Runtime

setImmediate after I/O

Inside an I/O callback, setImmediate usually runs before a zero-delay timer.

Real use: This appears in servers, CLIs, file watchers, and test suites that schedule follow-up work after I/O.
Open case
Guided - Node.js Runtime

EventEmitter listeners are sync

EventEmitter.emit calls listeners immediately on the current stack.

Real use: This explains surprising stack traces and error timing in Express apps, streams, queues, and internal event buses.
Open case
Guided - Node.js Runtime

Stream backpressure

When stream.write returns false, wait for drain before writing more.

Real use: This prevents memory spikes in file uploads, log pipelines, CSV exports, proxies, and Node API gateways.
Open case
Guided - Node.js Runtime

Unhandled rejection timing

A rejected promise reports as unhandled after the current turn if no catch is attached.

Real use: This is critical for background jobs, test failures, queue consumers, and process-level error monitoring.
Open case
Guided - Node.js Runtime

Top-level await blocks importers

A module with top-level await pauses evaluation of modules that import it.

Real use: This affects Next.js tooling, Node CLIs, config loaders, migrations, server startup, and test environments.
Open case
Guided - Node.js Runtime

libuv thread pool callback

Some Node work runs off the main thread, but callbacks return to the JS event loop.

Real use: This matters for password hashing, image processing, filesystem bursts, DNS, and API latency under load.
Open case
Guided - Node.js Runtime

AbortController cleanup

Aborting a fetch rejects the pending operation and prevents stale work.

Real use: Use this in search boxes, route transitions, server fetch timeouts, and background sync cleanup.
Open case
Guided - Node.js Runtime

Worker thread offload

Move CPU-heavy work to a worker so the main event loop keeps responding.

Real use: Use workers for image resizing, PDF generation, analytics crunching, compression, and expensive parsing.
Open case
Guided - Node.js Runtime

AsyncLocalStorage request context

AsyncLocalStorage can preserve request context across async boundaries.

Real use: This powers request logging, tracing, tenant IDs, auth context, and observability in modern Node servers.
Open case
Guided - Real-World Bugs

React batched state log

State updates are scheduled, so logging state right after setState can show the old value.

Real use: This shows up in React forms, counters, analytics events, and logic that reads state immediately after updating it.
Open case
Guided - Real-World Bugs

Effect cleanup race

React runs cleanup for the previous effect before the next effect starts.

Real use: This prevents wrong profile data, flickering search results, and stale route content in React apps.
Open case
Guided - Real-World Bugs

Stale closure timeout

A delayed callback remembers the values from when it was created.

Real use: This affects delayed notifications, retry callbacks, telemetry, and timeout-based cleanup logic.
Open case
Guided - Real-World Bugs

Fake timers vs promises

Advancing fake timers does not automatically flush every Promise microtask.

Real use: This is common in Jest/Vitest tests for debounced inputs, retries, loading spinners, and async React components.
Open case
Guided - Real-World Bugs

requestAnimationFrame vs timeout

requestAnimationFrame is aligned with the browser paint cycle; timers are general tasks.

Real use: This improves smoothness in drag interactions, charts, canvas work, scroll effects, and layout measurement.
Open case
Guided - Real-World Bugs

Debounce vs throttle

Debounce waits for quiet; throttle limits how often work can run.

Real use: Use debounce for search boxes and validation; use throttle for scroll, resize, and pointer tracking.
Open case
Guided - Real-World Bugs

Fetch abort race

Cancel stale requests so older responses cannot overwrite newer UI state.

Real use: This is essential in search, filters, route loaders, dashboards, and autocomplete components.
Open case
Guided - Real-World Bugs

WebSocket message task

WebSocket messages arrive as event tasks; they do not interrupt synchronous rendering.

Real use: This affects live dashboards, chats, trading screens, collaborative apps, and real-time notifications.
Open case
Guided - Real-World Bugs

Idle callback background work

requestIdleCallback runs low-priority work only when the browser has spare time.

Real use: This helps with analytics flushing, precomputing, non-urgent persistence, and performance-friendly cleanup.
Open case
Guided - Real-World Bugs

MutationObserver timing

MutationObserver callbacks run before timers after DOM changes are observed.

Real use: This matters in component libraries, rich text editors, analytics trackers, test utilities, and DOM measurement code.
Open case
Guided - Real-World Bugs

React effect cleanup missing

Effects that register timers or listeners must clean them up or old work keeps running after the component is gone.

Real use: This appears in dashboards, resize measurement, polling widgets, analytics listeners, and components that mount/unmount often.
Open case
Guided - Real-World Bugs

Next.js server action missing await

A server action can return success before persistence finishes if async work is started but not awaited.

Real use: This causes stale pages, early success toasts, lost errors, and confusing production logs in Next.js apps.
Open case
Guided - Real-World Bugs

Vitest fake timers and microtasks

Advancing timers is not the same as flushing promise jobs in tests.

Real use: This reduces flaky Vitest/Jest tests around retries, debounce, polling, loaders, and React async state.
Open case
Guided - Real-World Bugs

Express slow route blocking

CPU-heavy work inside a request handler blocks unrelated requests on the same event loop.

Real use: This affects PDF generation, image transforms, CSV exports, encryption, large JSON parsing, and analytics aggregation in Express/Fastify APIs.
Open case
Guided - Real-World Bugs

File upload backpressure bug

Ignoring stream backpressure lets upload buffers grow faster than the destination can write.

Real use: This causes upload memory spikes, slow proxies, stalled file imports, and high RSS in Node services.
Open case
Guided - Real-World Bugs

Redis/cache memory growth

Unbounded in-process caches retain data even when Redis or the database is the real source of truth.

Real use: This shows up in API gateways, profile caches, feature flag caches, permission lookups, and hot service processes.
Open case
Editable - Event Loop

Promise vs Timer

Microtasks run before timers, even when timer delay is 0.

Real use: This matters when mixing promises, timers, UI updates, API callbacks, and test assertions.
Open case
Editable - Event Loop

Multiple Timers

Timers are scheduled now, but run later by delay and queue order.

Real use: This appears in retry logic, staged UI transitions, test timers, and analytics scheduling.
Open case
Editable - Event Loop

Timer Inside Promise

Where a timer is scheduled changes its place in line.

Real use: This shows up when promise setup schedules fallback timers or cleanup work.
Open case
Editable - Event Loop

Blocking Loop Delays Timer

Timers cannot run while the call stack is blocked.

Real use: Large JSON parsing, export generation, sorting, and render-time calculations can freeze UI.
Open case
Editable - Promises

Promise Chain Return

Missing return breaks value flow through .then().

Real use: Promise chains in API mapping and test setup often fail from this exact missing return.
Open case
Editable - Promises

Promise.all

Promise.all waits for all success, but rejects on first failure.

Real use: Parallel fetches for dashboards, uploads, and fan-out service requests.
Open case
Editable - Promises

Promise.race vs Promise.any

race settles first; any fulfills first successful promise.

Real use: Fallback APIs, CDN mirrors, timeout races, and redundant request strategies.
Open case
Editable - Async/Await

Sequential vs Parallel Await

Sequential awaits add wait time; parallel waits for the slowest request.

Real use: Page data loading, dashboard widgets, service fan-out, and batch validations.
Open case
Editable - Async/Await

Missing Await

Without await, later code continues before the async result is ready.

Real use: Form submits, auth checks, tests, saves, and redirects.
Open case
Editable - Async/Await

Async forEach Problem

forEach does not wait for async callbacks.

Real use: Bulk saves, uploads, migrations, queue processing, and tests.
Open case
Editable - Memory

Uncleared Interval Leak

Intervals keep running and retaining captured memory unless cleared.

Real use: Polling, live dashboards, analytics pings, and rotating banners.
Open case
Editable - Performance

Microtask Flood

Too many microtasks can delay timers and make the app feel stuck.

Real use: Schedulers, batching systems, reactive updates, and retry loops.
Open case
Node - Async & Event Loop

Node queue priority

Node drains process.nextTick before Promise microtasks, then moves through timer, I/O, check, and close phases.

Real use: Debug flaky tests, CLI startup order, stream internals, and server callbacks that appear to run out of order.
Open case
Node - Files & Networking

fs.readFile and the thread pool

Async file work leaves the JS call stack, uses libuv, then returns a callback through the I/O queue.

Real use: Understand why servers can accept more requests while file reads are pending.
Open case
Node - Memory & Performance

Thread pool saturation

fs, crypto, zlib, and some DNS work share a limited libuv worker pool.

Real use: Find why password hashing or compression makes unrelated file operations slow.
Open case
Node - Files & Networking

HTTP request with database call

A request handler starts sync, awaits network/database work, then resumes when the promise settles.

Real use: See why response latency is often wait time, not JavaScript execution time.
Open case
Node - Streams & Buffers

Stream pipe with backpressure

Streams move chunks and pause reads when the writable side cannot keep up.

Real use: Process large files without loading the whole file into memory.
Open case
Node - Streams & Buffers

Buffers and encoding

Buffers store bytes; encoding controls how bytes become text.

Real use: Avoid corrupted uploads, broken signatures, and wrong file/network payloads.
Open case
Node - Memory & Performance

Memory leak: cache, listener, timer

Long-lived references stop garbage collection even when a request is finished.

Real use: Diagnose Node processes whose memory grows every hour.
Open case
Node - Memory & Performance

Large JSON parse blocks requests

CPU-heavy synchronous work blocks the event loop even if your server uses async I/O.

Real use: Explain slow API responses under large payloads or reporting endpoints.
Open case
Node - Async & Event Loop

Promise.all vs allSettled

Promise.all fails fast; allSettled keeps every result.

Real use: Build dashboards and batch jobs that show partial success instead of hiding useful data.
Open case
Node - Errors & Debugging

Centralized async errors

Rejected route promises need a centralized path to logging and response handling.

Real use: Avoid hanging requests and missing production errors.
Open case
Node - Node.js Fundamentals

CommonJS module cache

CommonJS modules execute once, then require returns the cached exports.

Real use: Understand shared singletons, config modules, and surprising test state.
Open case
Node - Security

Validation and rate limiting

Reject unsafe input early and limit abusive request bursts before expensive work starts.

Real use: Protect API servers from injection, crashes, and simple denial-of-service pressure.
Open case
Node - Testing

Testing async timers

Timer helpers and Promise microtasks are different things in tests.

Real use: Fix flaky Jest/Vitest tests for retries, debounce, and async UI.
Open case
Node - Deployment

Graceful shutdown

Production Node apps should stop accepting new work, finish active requests, then close resources.

Real use: Avoid dropped requests during deploys, restarts, and container shutdown.
Open case
Node - Interview Questions

Interview: explain the event loop

A strong event-loop answer connects stack, queues, async APIs, and real production consequences.

Real use: Prepare concise answers that also transfer to debugging real Node systems.
Open case
Node - Errors & Debugging

Error-first callback flow

Classic Node callbacks pass errors first so success code should only run after the error branch is checked.

Real use: Avoid sending duplicate responses or using missing data after fs, database, Redis, or legacy SDK callbacks fail.
Open case
Node - Async & Event Loop

setInterval drift under load

Intervals schedule ticks, but callbacks cannot run while the event loop is blocked.

Real use: Understand delayed polling, heartbeats, metrics flushes, and background jobs during CPU spikes.
Open case
Node - Async & Event Loop

nextTick starvation

A recursive process.nextTick loop can starve Promise callbacks, timers, and I/O.

Real use: Debug libraries that make servers feel frozen even though no synchronous loop is obvious.
Open case
Node - Async & Event Loop

setImmediate inside I/O

Inside an I/O callback, setImmediate is usually reached before a newly scheduled timer.

Real use: Explain ordering in fs callbacks, network handlers, and libraries that mix timers with setImmediate.
Open case
Node - Async & Event Loop

Promise.race request timeout

Promise.race settles with the first promise, but slower work may still continue unless you cancel it.

Real use: Build request timeouts without leaking pending fetches, database calls, or background tasks.
Open case
Node - Async & Event Loop

Promise.any fallback

Promise.any ignores rejections until one promise fulfills, then only fails if all reject.

Real use: Use redundant mirrors, cache fallbacks, and multi-region reads without failing on the first bad source.
Open case
Node - Files & Networking

readFileSync blocks server

Synchronous filesystem calls block the event loop and delay every other request in the process.

Real use: Avoid slow endpoints caused by reading templates, reports, or config files during requests.
Open case
Node - Files & Networking

DNS lookup and worker pressure

Some DNS work can share worker-pool capacity with fs, crypto, and zlib tasks.

Real use: Explain slow outbound requests when password hashing, compression, or file work is saturating the process.
Open case
Node - Memory & Performance

zlib compression uses workers

Compression is async, but it can still saturate libuv workers and delay other pool users.

Real use: Understand slow downloads, report exports, and API latency during compression bursts.
Open case
Node - Streams & Buffers

Full read vs stream memory

Reading a whole file allocates the full payload; streaming processes chunks and keeps memory flatter.

Real use: Build CSV imports, file downloads, log processors, and upload handlers that do not exhaust memory.
Open case
Node - Streams & Buffers

Stream error handling

Streams can fail after work starts, so pipeline-style error handling is safer than manual pipe chains.

Real use: Prevent hanging uploads, broken proxies, and files left half-written after stream failures.
Open case
Node - Streams & Buffers

Buffer base64 payload

Base64 is text that represents bytes; converting back to a Buffer is required before binary processing.

Real use: Handle file uploads, JWT pieces, webhooks, images, and API payloads without corrupting bytes.
Open case
Node - Memory & Performance

Worker thread for CPU work

Worker threads move CPU-heavy JavaScript off the main event loop.

Real use: Keep APIs responsive while parsing, transforming, hashing, or calculating expensive results.
Open case
Node - Deployment

Cluster request distribution

Multiple Node processes can share traffic so one blocked process does not stop every request.

Real use: Understand PM2 cluster mode, Node cluster, container replicas, and horizontal scaling.
Open case
Node - Errors & Debugging

Unhandled rejection policy

Unhandled promise rejections must be logged and handled deliberately instead of silently ignored.

Real use: Prevent invisible failed jobs, stuck requests, and production incidents with missing alerts.
Open case