Registry / http-networking / xresilient

xresilient

JSON →
library0.8.2jsnpmunverified

Builds regenerative, resumable Node.js readable streams that automatically retry on failure. Version 0.8.2 – stable, with TypeScript definitions included. Unlike manual retry logic or generic stream wrappers, xresilient tracks bytes read and supports range headers for resumable HTTP downloads. The stream can retry a user-supplied generator function a configurable number of times (default 5), emitting 'retry' and 'error' events. It extends stream.ReadableOptions, allowing custom destroyer functions and seamless integration with Node's stream pipeline. Suitable for fetching large files over unreliable networks.

npm install xresilient
INSTALL
IMPORT
SIG · XRESILIENT
X
xresilient
http-networkingjavascriptv0.8.2
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.

default
import xresilient from 'xresilient'
const xresilient = require('xresilient').default
ESM default export – in CommonJS, require returns the default export directly, no .default needed.
ResilientStream
import { ResilientStream } from 'xresilient'
const ResilientStream = require('xresilient').ResilientStream
Named export for the stream class, useful for type checking or extending.
xresilient
const xresilient = require('xresilient')
const { xresilient } = require('xresilient')
CJS: require returns the default export directly, not a named export.

Creates a resumable stream that re-fetches a file with Range header on error, piping to disk.

import xresilient from 'xresilient'; import request from 'request'; import fs from 'fs'; const retriableStream = xresilient( function returnStream({ bytesRead, retryCount }) { console.log(`Retry #${retryCount}, bytes so far: ${bytesRead}`); return request.get('https://example.com/file.bin', { headers: { Range: `bytes=${bytesRead}-` }, }); }, { retries: 3 } ); retriableStream.pipe(fs.createWriteStream('file.bin')); retriableStream.on('retry', (slice) => { console.log('Retrying...', slice); }); retriableStream.on('error', (err) => { console.error('Failed after retries:', err.message); });
Debug
Known issues
gotchaThe generator function must return a Readable stream; returning a destroyed or ended stream triggers retries or ends the resilient stream.
fix
Ensure fn always returns a valid, non-ended Readable stream unless you intend to end the resilient stream.
affects: >=0.0.0
gotchaThe 'error' event is only emitted after all retries are exhausted. Early errors do not surface directly.
fix
Listen to the 'retry' event to be notified of errors during retries, or check retryCount in the generator.
affects: >=0.0.0
gotchaIf the underlying stream emits a 'close' event prematurely, the retry logic may not trigger because it's not an 'error' event.
fix
Wrap the stream to convert 'close' into 'error' if needed, or rely only on 'error' events.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: xresilient is not a function
CommonJS require returns an object with default property in some bundlers.
fix
Use const xresilient = require('xresilient').default instead of require('xresilient').
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
The underlying stream was destroyed but the generator function returned a stale stream.
fix
Ensure the generator creates a new stream each invocation, and avoid reusing destroyed streams.
Unhandled 'error' event in xresilient stream
No error listener attached; errors after retries are exhausted propagate unhandled.
fix
Add `retriableStream.on('error', ...)` to handle final errors.
Upgrade
Version history
0.8.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources
xresilient — npm install xresilient · libregistry