All quizzesHard
Cross-Cutting Concerns — Series 2
Preview — 3 of 10 questions
What does bufferLogs: true accomplish?
javascript
const app = await NestFactory.create(AppModule, { bufferLogs: true });
app.useLogger(app.get(PinoLogger));
await app.listen(3000);AIt batches log writes to reduce syscalls under load
BIt holds back everything Nest logs during bootstrap and replays it through the custom logger once useLogger() is called — otherwise those early lines would have already gone out through the default console logger, unstructured
CIt suppresses bootstrap logging entirely
DIt stores logs in memory so a later request can retrieve them
What does app.close() guarantee, and what does it not?
javascript
process.on('SIGTERM', async () => {
await app.close();
});AIt waits indefinitely for every open connection, including idle keep-alive ones, to close on its own
BIt aborts in-flight requests immediately so shutdown is instant
CIt has no effect unless enableShutdownHooks() was called
DIt stops accepting new connections and runs the shutdown hooks, but long-running handlers and idle keep-alive sockets can keep the process alive past the orchestrator's grace period — so a real drain also needs a readiness probe flipped to failing first, and bounded handler durations
Why should the liveness probe not check the database?
javascript
@Get('health/live') live() { return this.health.check([]); }
@Get('health/ready') ready() {
return this.health.check([() => this.db.pingCheck('database')]);
}ABecause liveness answers "should this process be restarted?" — and a database outage is not something a restart fixes, so making liveness depend on it turns a dependency blip into a restart storm across every instance
BBecause liveness probes are called too frequently for any I/O to be acceptable
CBecause Terminus forbids indicators on liveness endpoints
DBecause readiness and liveness must check disjoint sets of dependencies by specification
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.