šŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
šŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

⚔ Total XP: 0|šŸ’» backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Logging the raw Morgan stream to stdout in production and never persisting it

// Wrong: logs vanish when the process restarts app.use(morgan('dev')); // Correct: pipe into a persistent Winston transport app.use(morgan('combined', { stream: { write: (msg) => logger.info(msg.trim()) } }));

The Solution //

app.use(morgan('dev')) only prints colorized text to the console — once the container restarts or the process exits, those logs are gone forever. In production, pipe Morgan's stream option into Winston (or another persistent transport/log aggregator) so requests are written to files or shipped to a log platform, not just flashed on a terminal nobody is watching.

The Error //

Setting AsyncLocalStorage context after asynchronous work has already started

// Wrong: store is set up after next() already ran downstream code next(); als.run({ reqId }, () => {}); // Correct: wrap the whole request inside run() als.run({ reqId }, () => { next(); });

The Solution //

als.run() must wrap the entire lifetime of the request — if you call it after an await or inside a callback that already escaped the original scope, code deeper in the chain will find an empty store because it isn't running inside that closure anymore. Wrap it at the very top of the request middleware, before calling next().

Continue Learning