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.

npm install request-debug
INSTALL
IMPORT
SIG · REQUEST-DEBUG
R
request-debug
http-networkingjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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.

request-debug function
const requestDebug = require('request-debug');
import requestDebug from 'request-debug';
This package is CommonJS-only. Using ES module `import` syntax will result in errors.
Enable debugging (direct invocation)
require('request-debug')(request);
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.
Enable debugging with custom handler
require('request-debug')(request, function(type, data, r) { console.log(type, data); });
require('request-debug')(request, { logger: console.log });
A custom handler must be a function provided as the second argument. It receives `type`, `data`, and the `Request` instance `r`.

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 issues
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`.
fix
Migrate to modern HTTP clients like `node-fetch`, `axios`, or Node.js's built-in `http`/`https` modules, and use their respective debugging or interceptor mechanisms. This library should not be used in new projects.
affects: >=0.1.0
gotchaThis module is CommonJS-only. It cannot be directly imported using ES module `import` syntax (`import requestDebug from 'request-debug'`).
fix
Always use `const requestDebug = require('request-debug');` to import the module.
affects: >=0.1.0
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`.
fix
Ensure `request-debug` is initialized and attached to the `request` instance before attempting to call `request.stopDebugging()`.
affects: >=0.1.0
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.
fix
When using `request-debug` to inspect response bodies, ensure that the `request` call includes a callback function to buffer the response. Alternatively, consider using the stream `data` events directly on the `request` object for debugging streamed responses.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'request'
The `request` package, a peer dependency, is not installed.
fix
Install the `request` module: `npm install request`
TypeError: require(...) is not a function
Attempted to use ES module `import` syntax or improperly destructured the CJS export, or `request` was not passed correctly.
fix
Ensure you are using `require('request-debug')(request);` (CommonJS syntax) and that the `request` module instance is correctly passed as the first argument.
TypeError: request.stopDebugging is not a function
Called `request.stopDebugging()` before `request-debug` was initialized for the `request` instance.
fix
Initialize `request-debug` with `require('request-debug')(request);` before attempting to call `request.stopDebugging()`.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
requestrequiredCore functionality relies on patching the `request` module instance to intercept HTTP(S) events.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
2
Amazon
1
Resources
request-debug — npm install request-debug · libregistry