Registry / http-networking / request-debug

request-debug

JSON →
library0.2.0jsnpmunverified

request-debug is a Node.js utility library designed to monitor and debug HTTP(S) requests made by the now-deprecated `request` module. It provides an easy way to intercept and log request headers, bodies (for POST), response headers, response bodies (if a callback is provided to `request`), redirects, and authentication challenges. The current stable version is 0.2.0, and due to its dependency on the unmaintained `request` library, its release cadence is effectively none, making it an abandoned project. Its key differentiator was its tight integration with `request`, patching the module instance directly to emit detailed event data for each request lifecycle stage, either to stderr or via a user-defined callback function.

http-networkingobservabilitytesting
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This package is CommonJS-only. Using ES module `import` syntax will result in errors.

const requestDebug = require('request-debug');

The debugging functionality is activated by immediately invoking the required module with the `request` instance as an argument. Omitting `(request)` will not enable debugging.

require('request-debug')(request);

A custom handler must be a function provided as the second argument. It receives `type`, `data`, and the `Request` instance `r`.

require('request-debug')(request, function(type, data, r) { console.log(type, data); });

This example demonstrates how to enable `request-debug` and make a sample HTTP request with basic authentication to an external service (`httpbin.org`), showing how the debug events are logged to the console (stderr by default). It includes a commented-out custom handler example.

const request = require('request'); const util = require('util'); // Enable request-debug, sending output to stderr by default require('request-debug')(request); // Alternatively, provide a custom handler function: // require('request-debug')(request, function(type, data, r) { // console.error(`[${type.toUpperCase()}] debugId: ${data.debugId}`); // console.error(util.inspect(data, { colors: true, depth: 3 })); // }); console.log('Making a debuggable HTTP request...'); request({ uri : 'https://httpbin.org/digest-auth/auth/user/pass', auth : { user : 'user', pass : 'pass', sendImmediately : false }, // IMPORTANT: rejectUnauthorized is only for example purposes to ignore self-signed certs // Do NOT use in production with untrusted certs. rejectUnauthorized : process.env.NODE_ENV !== 'production' ? false : true, headers: { 'User-Agent': 'request-debug-example' } }, function(err, res, body) { if (err) { console.error('Request failed:', err.message); } else { console.log('REQUEST RESULTS:'); console.log(' Status Code:', res.statusCode); console.log(' Body:', body.substring(0, 100) + '...'); } // Stop debugging once the process is complete (optional) if (request.stopDebugging) { request.stopDebugging(); } });
Debug
Known footguns
breakingThe `request-debug` library is built exclusively for and directly depends on the `request` module, which has been officially deprecated and is no longer maintained. This means `request-debug` is also effectively abandoned and may have security vulnerabilities inherited from `request`.
gotchaThis module is CommonJS-only. It cannot be directly imported using ES module `import` syntax (`import requestDebug from 'request-debug'`).
gotchaThe `request.stopDebugging()` function only becomes available on the `request` object after `require('request-debug')(request)` has been called. Attempting to call it before enabling debugging will result in a `TypeError`.
gotchaResponse bodies (`data.body` in the response event) are only buffered and made available by `request-debug` if the original call to `request` included a callback function. If `request` is used in a streaming or promise-based manner without a callback, the response body may be absent from debug data.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
bytedance
1
Resources