{"id":18749,"library":"resilient","title":"Resilient HTTP Client","description":"A fault-tolerant, reactive HTTP client for Node.js and browsers, designed for distributed systems and microservices. Version 0.4.0 (latest, last released in 2016, no recent updates) provides transparent server fallback, dynamic server discovery (e.g., via Consul), request retry/backoff, and client-side load balancing based on empirical server latency. It is middleware-oriented, lightweight (~9KB gzipped), dependency-free, and supports both callback and promise-based async requests. Differentiates from alternatives like Axios or Got by focusing on resilience patterns (circuit breaker, failover) inspired by Netflix's Ribbon and Chaos Engineering.","status":"maintenance","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/resilient-http/resilient.js","tags":["javascript","fault","tolerant","balance","ajax","http","https","xhr","request"],"install":[{"cmd":"npm install resilient","lang":"bash","label":"npm"},{"cmd":"yarn add resilient","lang":"bash","label":"yarn"},{"cmd":"pnpm add resilient","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CJS only; no ESM support.","wrong":"import resilient from 'resilient';","symbol":"resilient","correct":"const resilient = require('resilient');"},{"note":"The factory function returns a client instance; no class constructor.","wrong":"const client = new resilient.Client();","symbol":"ResilientClient","correct":"const client = resilient({ service: { basePath: '/api' } });"},{"note":"Middleware must be a function, not a string.","wrong":"client.use('middleware');","symbol":"middleware","correct":"client.use(middleware());"}],"quickstart":{"code":"const resilient = require('resilient');\nconst client = resilient({\n  service: {\n    basePath: '/api',\n    timeout: 5000,\n    retry: 2,\n    fallback: true\n  },\n  discovery: {\n    servers: ['http://server1.example.com', 'http://server2.example.com'],\n    interval: 30000\n  },\n  balancer: {\n    policy: 'roundRobin'\n  }\n});\n\nclient.get('/users', (err, res) => {\n  if (err) {\n    console.error('Request failed:', err.message);\n  } else {\n    console.log('Response:', res.body);\n  }\n});","lang":"javascript","description":"Creates a resilient client with static server discovery, retry, fallback, and round-robin load balancing, then performs a GET request."},"warnings":[{"fix":"Consider migrating to a maintained alternative like Axios with retry plugins or Got with timeout and retry.","message":"The package has not been updated since 2016; it uses outdated APIs and may not work with modern Node.js versions.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Upgrade Node.js to version 4 or higher.","message":"Node.js 4+ required; incompatible with Node.js versions below 4.","severity":"breaking","affected_versions":"<4"},{"fix":"Use client.get().then() is not available; wrap callbacks in promises.","message":"The client does not support promises natively (callback only). Using promises requires wrapping or a library like Bluebird.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Check for err.code and compare with resilient error constants.","message":"Errors from the client use custom error codes (e.g., 'RERR_REQUEST_FAILED'). Standard HTTP errors may not be caught.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set discovery options in constructor; no per-request override available.","message":"The discovery interval and retry count are global; cannot be overridden per-request.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install resilient --save'.","cause":"Package not installed or missing from node_modules.","error":"module 'resilient' not found"},{"fix":"Use const resilient = require('resilient');","cause":"Incorrect import: using ES6 import syntax or destructuring import.","error":"Uncaught TypeError: resilient is not a function"},{"fix":"Ensure resilient() is called with options and returns client object.","cause":"client is not properly initialized; perhaps called before module loaded or factory not invoked.","error":"TypeError: client.get is not a function"},{"fix":"Configure at least one server in discovery.servers or provide dynamic discovery URL.","cause":"No servers available or discovery fails; default server list empty.","error":"Error: connect ECONNREFUSED"},{"fix":"Check if err is truthy before accessing res.body.","cause":"The callback is called with (err, res) but res is undefined when error occurs.","error":"Cannot read property 'body' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}