Node.js Communication & Stakeholder Relations 3 — Questions and Answers
Question 1: Your Node.js service uses Server-Sent Events (SSE). How does SSE differ from WebSockets in stakeholder-facing communication scenarios?
- SSE is bidirectional; WebSockets are unidirectional
- SSE is server-to-client only and simpler; WebSockets support full bidirectional messaging (Correct answer)
- SSE requires a special protocol; WebSockets use HTTP
- They are identical in capability
Correct answer: SSE is server-to-client only and simpler; WebSockets support full bidirectional messaging
SSE is a unidirectional server-push mechanism over HTTP, while WebSockets provide full-duplex communication over a separate protocol.
Question 2: A DevOps stakeholder asks how to monitor your Node.js service health. Which built-in or common approach do you recommend?
- Check if the process appears in ps aux
- Expose a /health endpoint that reports status, uptime, and memory usage (Correct answer)
- Count open file descriptors
- Restart the service daily as a health strategy
Correct answer: Expose a /health endpoint that reports status, uptime, and memory usage
A /health endpoint is the standard pattern for health checks, integrating with load balancers, Kubernetes probes, and monitoring tools.
Question 3: A team member proposes using process.send() for inter-process communication in a Node.js cluster. When is this appropriate?
- Never; use HTTP between workers
- When communicating between a cluster master and its worker processes (Correct answer)
- Only for communicating with child_process.exec children
- For all external API calls
Correct answer: When communicating between a cluster master and its worker processes
process.send() works specifically for IPC between a cluster master and forked workers, or between parent and child processes created with fork().
Question 4: A stakeholder asks why some Node.js API responses arrive out of order. You suspect Promise.all() behavior. What do you explain?
- Promise.all() guarantees sequential execution
- Promise.all() runs promises concurrently; results are in input order but completion times vary (Correct answer)
- Promise.all() randomly shuffles results
- Promise.all() only resolves the fastest promise
Correct answer: Promise.all() runs promises concurrently; results are in input order but completion times vary
Promise.all() executes concurrently and returns results in the original input order, but individual operations complete at different times.
Question 5: You are writing a Node.js library for external developers. Which approach best communicates breaking changes?
- Change the function name without notice
- Follow semantic versioning — bump the major version and document changes in a CHANGELOG (Correct answer)
- Add a console.warn inside the function
- Send an email to known users
Correct answer: Follow semantic versioning — bump the major version and document changes in a CHANGELOG
Semantic versioning signals breaking changes via major version bumps, and a CHANGELOG documents what changed and migration steps.
Question 6: A QA engineer reports that your Node.js EventEmitter fires events before listeners are registered. What do you advise?
- Use a setTimeout to delay event emission
- Register listeners synchronously before emitting, or use EventEmitter.once() with deferred emission (Correct answer)
- Switch to callbacks instead
- Emit events only in setTimeout callbacks
Correct answer: Register listeners synchronously before emitting, or use EventEmitter.once() with deferred emission
Listeners must be registered before events fire since EventEmitter does not queue past events; restructuring initialization order or using deferred emission solves this.
Question 7: A stakeholder wants structured logging for their Node.js microservice. Which library is the industry standard recommendation?
- console.log with JSON.stringify
- Winston or Pino with JSON output, log levels, and transport configuration (Correct answer)
- Custom file writers using fs.appendFile
- Only process.stdout.write
Correct answer: Winston or Pino with JSON output, log levels, and transport configuration
Winston and Pino provide structured JSON logging, configurable log levels, and transport routing, making them the standard choice for production Node.js services.
Your Node.js service uses Server-Sent Events (SSE).
How does SSE differ from WebSockets in stakeholder-facing communication scenarios?