{"id":16400,"library":"iso-stream-http","title":"Isomorphic HTTP Stream","description":"iso-stream-http is a JavaScript module that provides an isomorphic (browser and Node.js compatible) implementation of Node.js's native `http` module. Currently at version 0.1.2, it aims to replicate the Node.js HTTP client API as closely as possible within browser environments, offering pseudo-streaming capabilities where the entire response is held in memory, and in some modern browsers, true streaming. It is heavily inspired by and intended to replace `stream-http`. The project appears to have a slow release cadence, with the latest update being minor bug fixes. Key differentiators include its isomorphic nature, aiming for Node.js API parity in the browser, and its focus on providing data before the request completes, which is a significant feature for handling larger responses efficiently in both client and server contexts.","status":"active","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/hugomrdias/iso-stream-http","tags":["javascript","http","stream","streaming","fetch","node http"],"install":[{"cmd":"npm install iso-stream-http","lang":"bash","label":"npm"},{"cmd":"yarn add iso-stream-http","lang":"bash","label":"yarn"},{"cmd":"pnpm add iso-stream-http","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primary HTTP client for making requests. The README examples primarily use CommonJS `require`, but named ESM imports are the modern standard.","wrong":"const http = require('iso-stream-http').http;","symbol":"http","correct":"import { http } from 'iso-stream-http';"},{"note":"Secure HTTP client for making HTTPS requests. Functions identically to `http` but for secure connections.","wrong":"const https = require('iso-stream-http').https;","symbol":"https","correct":"import { https } from 'iso-stream-http';"},{"note":"A helper function that detects the URL protocol (http/https) and returns the appropriate client (`http` or `https`) in Node.js.","wrong":"const getRequest = require('iso-stream-http').getRequest;","symbol":"getRequest","correct":"import { getRequest } from 'iso-stream-http';"}],"quickstart":{"code":"const { http } = require('iso-stream-http');\n\nconsole.log('Fetching /bundle.js...');\n\nhttp.get('http://localhost:8080/bundle.js', function (res) {\n  console.log(`Status: ${res.statusCode}`);\n  console.log('Headers:', res.headers);\n\n  let data = '';\n  res.on('data', function (buf) {\n    data += buf.toString();\n    process.stdout.write('Received chunk: ' + buf.length + ' bytes\\n');\n  });\n\n  res.on('end', function () {\n    console.log('\\n__END__');\n    // In a browser, you might update the DOM here:\n    // document.getElementById('result').innerHTML += '<br>__END__';\n    console.log('Full response data length:', data.length);\n  });\n\n  res.on('error', function(err) {\n    console.error('Response error:', err);\n  });\n}).on('error', function(err) {\n  console.error('Request error:', err);\n});\n\n// To make this runnable, you would need a simple HTTP server\n// serving a 'bundle.js' file on http://localhost:8080\n// Example server (Node.js):\n/*\nconst server = require('http').createServer((req, res) => {\n  if (req.url === '/bundle.js') {\n    res.writeHead(200, { 'Content-Type': 'application/javascript' });\n    res.end('console.log(\"hello from bundle.js\");');\n  } else {\n    res.writeHead(404); res.end('Not Found');\n  }\n});\nserver.listen(8080, () => console.log('Server listening on port 8080'));\n*/","lang":"javascript","description":"Demonstrates how to make an HTTP GET request, handle streaming data chunks, and detect the end of the response using `iso-stream-http`'s Node.js-like API."},"warnings":[{"fix":"Avoid relying on `http.Agent` for browser-based requests. For advanced network control in the browser, consider `fetch` API options or browser-specific network configurations, which are outside the scope of this library.","message":"The `http.Agent` in `iso-stream-http` is only a stub and does not provide actual agent functionality as it would in Node.js. Users expecting connection pooling or proxying via `http.Agent` will find it non-functional.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Do not attempt to use socket-specific events or methods. For request timeouts, use `options.requestTimeout` which is a library-specific alternative, but note it behaves differently than Node's `setTimeout`.","message":"Many socket-level events and operations available in Node.js's `http.ClientRequest` are not implemented. This includes 'socket', 'connect', 'upgrade', 'continue' events, and `request.setTimeout`. The browser's security model restricts direct socket access.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Be aware of browser-enforced header limitations. For debugging, inspect `message.headers` (which is processed by the browser) rather than expecting raw headers. Do not rely on `trailers` for critical response data.","message":"Certain HTTP headers cannot be set or retrieved due to browser security restrictions (e.g., 'referer', 'cookie', 'host'). Additionally, `message.rawHeaders` might not exactly match what the server sends, and `message.trailers` and `message.rawTrailers` will always be empty. `message.httpVersion` is also missing.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Assume redirects are handled transparently. If redirect URLs or statuses are required, a server-side proxy or a different browser-native API (like `fetch` with `redirect: 'manual'`) would be necessary.","message":"HTTP redirects (301/302) are followed silently by the browser. This means `iso-stream-http` will not expose the intermediate redirect responses, only the final destination. This differs from Node.js where redirects are often observable.","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":"Update `iso-stream-http` to version 0.1.2 or later, as this specific error was addressed in that release.","cause":"An issue with the internal resolution of the `https` module, particularly in certain environments or configurations.","error":"https does not exist"},{"fix":"Remove any code attempting to interact with the underlying socket or listen for socket-specific events. The library does not expose this level of control. Focus on `data`, `end`, and `error` events for the response stream.","cause":"Attempting to attach event listeners like 'socket' or 'connect' to the `ClientRequest` object, which are not supported as `http.Agent` is a stub and direct socket access is not available in the browser implementation.","error":"TypeError: Cannot read properties of undefined (reading 'on') when trying to attach socket event listener"}],"ecosystem":"npm"}