{"id":17924,"library":"request-debug","title":"request-debug","description":"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.","status":"abandoned","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/request/request-debug","tags":["javascript","request","debug","http","https","headers"],"install":[{"cmd":"npm install request-debug","lang":"bash","label":"npm"},{"cmd":"yarn add request-debug","lang":"bash","label":"yarn"},{"cmd":"pnpm add request-debug","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core functionality relies on patching the `request` module instance to intercept HTTP(S) events.","package":"request","optional":false}],"imports":[{"note":"This package is CommonJS-only. Using ES module `import` syntax will result in errors.","wrong":"import requestDebug from 'request-debug';","symbol":"request-debug function","correct":"const requestDebug = require('request-debug');"},{"note":"The debugging functionality is activated by immediately invoking the required module with the `request` instance as an argument. Omitting `(request)` will not enable debugging.","wrong":"require('request-debug');","symbol":"Enable debugging (direct invocation)","correct":"require('request-debug')(request);"},{"note":"A custom handler must be a function provided as the second argument. It receives `type`, `data`, and the `Request` instance `r`.","wrong":"require('request-debug')(request, { logger: console.log });","symbol":"Enable debugging with custom handler","correct":"require('request-debug')(request, function(type, data, r) { console.log(type, data); });"}],"quickstart":{"code":"const request = require('request');\nconst util = require('util');\n\n// Enable request-debug, sending output to stderr by default\nrequire('request-debug')(request);\n\n// Alternatively, provide a custom handler function:\n// require('request-debug')(request, function(type, data, r) {\n//   console.error(`[${type.toUpperCase()}] debugId: ${data.debugId}`);\n//   console.error(util.inspect(data, { colors: true, depth: 3 }));\n// });\n\nconsole.log('Making a debuggable HTTP request...');\n\nrequest({\n    uri  : 'https://httpbin.org/digest-auth/auth/user/pass',\n    auth : {\n        user : 'user',\n        pass : 'pass',\n        sendImmediately : false\n    },\n    // IMPORTANT: rejectUnauthorized is only for example purposes to ignore self-signed certs\n    // Do NOT use in production with untrusted certs.\n    rejectUnauthorized : process.env.NODE_ENV !== 'production' ? false : true,\n    headers: {\n        'User-Agent': 'request-debug-example'\n    }\n}, function(err, res, body) {\n    if (err) {\n        console.error('Request failed:', err.message);\n    } else {\n        console.log('REQUEST RESULTS:');\n        console.log('  Status Code:', res.statusCode);\n        console.log('  Body:', body.substring(0, 100) + '...');\n    }\n    // Stop debugging once the process is complete (optional)\n    if (request.stopDebugging) {\n        request.stopDebugging();\n    }\n});\n","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The `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`.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Always use `const requestDebug = require('request-debug');` to import the module.","message":"This module is CommonJS-only. It cannot be directly imported using ES module `import` syntax (`import requestDebug from 'request-debug'`).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure `request-debug` is initialized and attached to the `request` instance before attempting to call `request.stopDebugging()`.","message":"The `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`.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"Response 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Install the `request` module: `npm install request`","cause":"The `request` package, a peer dependency, is not installed.","error":"Error: Cannot find module 'request'"},{"fix":"Ensure you are using `require('request-debug')(request);` (CommonJS syntax) and that the `request` module instance is correctly passed as the first argument.","cause":"Attempted to use ES module `import` syntax or improperly destructured the CJS export, or `request` was not passed correctly.","error":"TypeError: require(...) is not a function"},{"fix":"Initialize `request-debug` with `require('request-debug')(request);` before attempting to call `request.stopDebugging()`.","cause":"Called `request.stopDebugging()` before `request-debug` was initialized for the `request` instance.","error":"TypeError: request.stopDebugging is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}