Skip to content
JavaScript·Intermediate·Conceptual·1 min read

Why can module-level state be unsafe on a server?

Short interview answer

A server module can be cached across requests, so mutable top-level state may leak or mix request-specific data. Keep request state within the request lifecycle and use deliberate external stores for shared state.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to JavaScript modules

Related questions