{"id":17393,"library":"urllib-sync","title":"Synchronous HTTP Request Utility","description":"This package provides a synchronous HTTP request utility for Node.js, built on top of `urllib` and utilizing Node.js's `spawnSync` module to achieve blocking I/O. The current stable version is 1.1.4, and it has not been updated in approximately nine years, indicating it is no longer maintained. Its primary function is to perform HTTP requests that halt the Node.js event loop until a response is received, a pattern generally considered an anti-pattern in asynchronous Node.js environments. Key differentiators include its explicit synchronous operation, contrasting with the typically non-blocking nature of Node.js. It explicitly states support only for Node.js v0.11.13+ and does not support features like response streams or custom HTTP agents, limiting its utility for modern applications requiring efficient handling of large data or complex network interactions.","status":"abandoned","version":"1.1.4","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/node-modules/urllib-sync","tags":["javascript","http","sync","request"],"install":[{"cmd":"npm install urllib-sync","lang":"bash","label":"npm"},{"cmd":"yarn add urllib-sync","lang":"bash","label":"yarn"},{"cmd":"pnpm add urllib-sync","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency providing the underlying HTTP request logic, wrapped by urllib-sync for synchronous execution.","package":"urllib"}],"imports":[{"note":"urllib-sync is a CommonJS module. Attempting to use ESM `import` will result in a runtime error.","wrong":"import { request } from 'urllib-sync';\n// Error: require is not defined in ES module scope","symbol":"request","correct":"const { request } = require('urllib-sync');"},{"note":"The package exports an object with a `request` method, not the method directly as a default export.","wrong":"const urllibSync = require('urllib-sync');\nurllibSync(); // TypeError: urllibSync is not a function","symbol":"request","correct":"const request = require('urllib-sync').request;"}],"quickstart":{"code":"const { request } = require('urllib-sync');\n\ntry {\n  console.log('Making a synchronous HTTP request...');\n  // This will block the Node.js event loop until the request completes.\n  const res = request('https://www.google.com');\n  \n  console.log(`Status: ${res.status}`);\n  console.log('Headers:');\n  for (const key in res.headers) {\n    console.log(`  ${key}: ${res.headers[key]}`);\n  }\n  // Note: res.data is a Buffer by default. Convert to string for display.\n  console.log(`Body snippet: ${res.data.toString().substring(0, 100)}...`);\n\n  // Example with options (e.g., method, data, timeout)\n  // const postData = JSON.stringify({ key: 'value' });\n  // const postRes = request('https://httpbin.org/post', {\n  //   method: 'POST',\n  //   data: postData,\n  //   headers: { 'Content-Type': 'application/json' },\n  //   timeout: 5000 // In milliseconds\n  // });\n  // console.log(`POST Status: ${postRes.status}, Body: ${postRes.data.toString()}`);\n\n} catch (error) {\n  console.error('Synchronous request failed:', error.message);\n}\n","lang":"javascript","description":"This quickstart demonstrates how to make a basic synchronous GET request using `urllib-sync`. It fetches content from a URL and logs the status, headers, and a snippet of the response body. It highlights the blocking nature of the request and provides commented-out examples for POST requests and options."},"warnings":[{"fix":"Do not use `urllib-sync` in modern Node.js applications. Prefer native `fetch` (Node.js v18+) or packages like `node-fetch`, `axios`, or the original `urllib` (which is asynchronous) for non-blocking HTTP requests.","message":"This package explicitly supports only Node.js v0.11.13+. It is incompatible with all modern Node.js versions (v12+ onwards) due to significant changes in Node.js internals and API availability.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always use asynchronous HTTP request libraries (e.g., `fetch`, `axios`, `urllib`'s async methods) to maintain a non-blocking event loop. Refactor code to use `async/await` or Promises.","message":"Using synchronous HTTP requests in Node.js will block the entire event loop, making your application unresponsive. This is a severe performance anti-pattern and should be avoided in server-side or long-running applications.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For stream support or custom agents, you must use an asynchronous HTTP client like `urllib` (the non-sync version), `node-fetch`, or `axios`.","message":"The package does not support streams or custom HTTP agents. This limits its use cases, especially for handling large responses efficiently or integrating with proxy/advanced networking setups.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to actively maintained asynchronous HTTP clients to ensure security, compatibility, and access to modern features and performance optimizations.","message":"The package is effectively abandoned, with its last publish nearly a decade ago and no updates to support modern Node.js versions or fix potential vulnerabilities or bugs. Its underlying approach (synchronous HTTP) is generally deprecated in Node.js best practices.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"This package is incompatible with modern Node.js. Update your application to use asynchronous HTTP clients instead of `urllib-sync`.","cause":"urllib-sync relies on internal Node.js APIs (like `spawnSync` from `child_process`) that have changed or become incompatible in newer Node.js versions, breaking the package's functionality.","error":"Error: The 'child_process.spawnSync' API is not available on this Node.js version."},{"fix":"urllib-sync is a CommonJS package. Either refactor your project to use CommonJS modules or migrate your HTTP requests to a modern, ESM-compatible asynchronous library like `node-fetch` or native `fetch`.","cause":"Attempting to use `require('urllib-sync')` in a Node.js environment configured for ECMAScript Modules (ESM) where CommonJS `require` is not directly available.","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Ensure you are destructuring the `request` function correctly: `const { request } = require('urllib-sync');` or accessing it as a property: `const request = require('urllib-sync').request;`","cause":"The package exports an object with a `request` method, not the function directly. If you `require('urllib-sync')` and try to call the result, it will fail.","error":"TypeError: request is not a function (or similar, if trying to call the module directly)"}],"ecosystem":"npm","meta_description":null}