CRT-600 practice question 23 of 30

A developer has a web server running with Node.js. The command to start the web server is node server.js. The web server started having latency issues. Instead of a one second turnaround for web requests, the developer now sees a five second turnaround. Which command can the web developer run to see what the module is doing during the latency period?

Full set: 223 questions
Answer options
A: NODE_DEBUG=true node server.js
B: DEBUG=http, https node server.js
C: NODE_DEBUG=http,https node server.js Correct answer
D: DEBUG=true node server.js
Correct Answer:
C. NODE_DEBUG=http,https node server.js
Explanation

The NODEDEBUG environment variable is a built-in utility in Node.js for enabling debug logging for specific core modules. To investigate latency in a web server, the developer needs to inspect the internal workings of the http and https modules. Setting NODEDEBUG=http,https instructs the Node.js runtime to output detailed, timestamped diagnostic information from these modules to stderr. This allows the developer to trace the request and response lifecycle and identify the specific operations causing the delay.

Why Incorrect

A. NODEDEBUG requires a comma-separated list of core module names to enable their specific debug logs; a generic value like true is not valid syntax for this purpose.
B. The DEBUG environment variable is conventionally used by user-land modules (e.g., Express.js) that leverage the debug library, not for Node.js core modules like http.
D. The DEBUG variable is for user-land modules, not core Node.js modules, and true is not the standard syntax for enabling specific module logs with it.

References

1. Node.js Official Documentation

Command-line options

Environment variables: The documentation explicitly defines the usage of NODEDEBUG. It states: "NODEDEBUG=module[

...]: '

'-separated list of core modules that should print debug information." This directly supports the syntax and purpose described in option C.

Source: Node.js v18.17.0 Documentation

"Environment Variables"

NODEDEBUG=module[

...] section.

2. Node.js Official Documentation

util module API: The documentation for util.debuglog(section) explains how this mechanism works internally. It clarifies that logs are enabled when the section name (e.g.

'http') appears in the NODEDEBUG environment variable.

Source: Node.js v18.17.0 Documentation

"Utility Module"

util.debuglog(section[

callback]) section.

Scroll to Top