{"id":17254,"library":"http-debug","title":"http-debug: Simple HTTP(S) Debugger","description":"http-debug is a lightweight utility designed to provide verbose debugging output for Node.js `http` and `https` requests. It operates by patching Node's built-in `http` and `https` modules to intercept and log request, write, end, and socket events to `stderr`. The current stable version is `0.1.2`. Given its low version number and the age of the provided changelog, the project appears to have a very slow or effectively ceased release cadence, last updated around 2013-2014. Its primary differentiator is its simplicity and direct global patching approach, allowing for debugging without modifying application code for each request, though this can lead to conflicts. It supports enabling debugging via `process.env.HTTP_DEBUG` or by setting `http.debug` at runtime, offering different verbosity levels.","status":"abandoned","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/jmervine/node-http-debug","tags":["javascript","debug","debugging","debugger","http","https","request"],"install":[{"cmd":"npm install http-debug","lang":"bash","label":"npm"},{"cmd":"yarn add http-debug","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-debug","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This library predates widespread ESM adoption and primarily supports CommonJS `require()` syntax. It modifies Node's global http module.","wrong":"import { http } from 'http-debug';","symbol":"http","correct":"const http = require('http-debug').http;"},{"note":"Similar to `http`, this imports the patched `https` module. Ensure you use `require()`.","wrong":"import { https } from 'http-debug';","symbol":"https","correct":"const https = require('http-debug').https;"},{"note":"The debugging level is set directly on the imported `http` or `https` object (which are effectively Node's global modules). It's not an export itself.","wrong":"const debug = require('http-debug').debug; debug = 2;","symbol":"debug state","correct":"http.debug = 2;"}],"quickstart":{"code":"const httpDebug = require('http-debug');\nconst http = httpDebug.http;\n\n// Set debugging level to verbose (2).\n// 0: off, 1: on (request, write, end), 2: verbose (on + error, socket events)\nhttp.debug = 2;\n\n// Alternatively, set via environment variable before running:\n// process.env.HTTP_DEBUG = '2';\n\nconsole.log('Making an HTTP GET request to mervine.net...');\nconsole.log('Debug output will appear on stderr.');\n\nhttp.get('http://mervine.net/', (res) => {\n   let data = '';\n   res.on('data', (chunk) => { data += chunk; });\n   res.on('end', () => {\n      console.log(`\\nHTTP Response Status Code: ${res.statusCode}`);\n      console.log(`Content length: ${data.length} bytes`);\n   });\n}).on('error', (err) => {\n   console.error('Error during HTTP request:', err.message);\n});\n\n// Example for HTTPS (uncomment to use)\n// const https = httpDebug.https;\n// https.debug = 2;\n// https.get('https://example.com/', (res) => {\n//    // ... handle response ...\n// }).on('error', (err) => {\n//    console.error('Error during HTTPS request:', err.message);\n// });","lang":"javascript","description":"This quickstart demonstrates how to import and enable verbose HTTP request debugging using http-debug, then makes a sample HTTP GET request to observe the detailed output on stderr."},"warnings":[{"fix":"Avoid using `http-debug` in environments where other global `http`/`https` interceptors are present. Consider alternative debugging methods like network proxies or `console.log` on `request.on('request')` events for complex scenarios. Given its age, it might also conflict with modern Node.js versions or features.","message":"This library globally patches Node.js's native `http` and `https` modules. This behavior can lead to conflicts if other libraries or your application also attempt to patch or wrap these modules, causing unpredictable behavior or crashes.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Be mindful of the precedence. If you want to control debugging solely via environment variables, ensure `http.debug` (or `https.debug`) is not explicitly set in your code after the module is loaded.","message":"The `http.debug` property takes precedence over `process.env.HTTP_DEBUG`. If both are set, the runtime assignment to `http.debug` will override the environment variable.","severity":"gotcha","affected_versions":">=0.1.2"},{"fix":"For new projects or existing projects needing active support, consider using modern debugging tools like Node.js's built-in debugger, `process.env.NODE_DEBUG`, dedicated network proxies (e.g., Fiddler, Charles, mitmproxy), or more actively maintained HTTP client debugging utilities.","message":"This package is very old (last updated around 2013-2014) and likely unmaintained. It relies on a global patching strategy that is generally discouraged in modern Node.js development due to potential side effects and conflicts.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Ensure your project uses CommonJS (`.js` files with `require`) or a build setup that correctly transpiles `require` calls if you're using ES Modules.","message":"The library primarily uses CommonJS `require()` syntax and may not be compatible with ES Modules (`import`) without additional transpilation or specific Node.js loader configurations, which are not explicitly supported.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure `const http = require('http-debug').http;` is called before accessing `http.debug`. Verify `http-debug` is installed and accessible.","cause":"Attempting to set `http.debug` before `http-debug` has correctly patched the `http` module, or if `http-debug` was not properly imported.","error":"TypeError: Cannot read properties of undefined (reading 'debug')"},{"fix":"Use `const http = require('http-debug').http;` to correctly import the patched `http` module.","cause":"The `http` object from `http-debug` was not correctly imported or assigned to a variable, or an `import` statement was used instead of `require`.","error":"ReferenceError: http is not defined"},{"fix":"Run `npm install http-debug` to install the package.","cause":"The `http-debug` package is not installed in the project's `node_modules`.","error":"Error: Cannot find module 'http-debug'"}],"ecosystem":"npm","meta_description":null}