The `toxiproxy-node-client` is a JavaScript and TypeScript client library for interacting with Toxiproxy, a powerful tool developed by Shopify for simulating real-world network conditions such as high latency, bandwidth limitations, and connection drops. This library, currently at stable version 4.0.0, provides a programmatic interface to configure Toxiproxy proxies and add various network 'toxics' to test the resilience and error handling of applications. While there isn't a fixed public release cadence, major versions like v4 typically introduce significant API updates or broader compatibility. Its key differentiator is being the primary Node.js interface for Toxiproxy, enabling developers to integrate network chaos engineering directly into their Node.js testing and development workflows without manual intervention. It ships with full TypeScript type definitions, making it suitable for both JavaScript and TypeScript projects.
npm install toxiproxy-node-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a Toxiproxy client, set up a proxy for a Redis instance, add a bandwidth-limiting toxic, and then clean up both the toxic and the proxy. It includes error handling and guidance for ensuring the Toxiproxy server is running.
For ESM/TypeScript, use `import { SymbolName } from 'toxiproxy-node-client';`. For CommonJS, use `const client = require('toxiproxy-node-client'); const SymbolName = client.SymbolName;`Before running your Node.js application, start the Toxiproxy server. The easiest way is using Docker: `docker run --rm -p 8474:8474 ghcr.io/shopify/toxiproxy:latest`.
Ensure all proxy names are unique. Consider appending a timestamp or a UUID to proxy names, especially in automated testing environments.
Provide unique names for each toxic you add to a proxy. If applying multiple toxics of the same type, differentiate their names.
Start the Toxiproxy server, for example, using Docker: `docker run --rm -p 8474:8474 ghcr.io/shopify/toxiproxy:latest`. Verify that the `Toxiproxy` client is configured to connect to the correct endpoint.
Use a unique name for each proxy. In testing scenarios, consider programmatically generating unique names (e.g., `my-proxy-${Date.now()}`).Explicitly specify the toxic type, for example, `const toxicBody: ICreateToxicBody<Bandwidth> = { ... };`. Ensure you have imported the specific toxic type (e.g., `Bandwidth`) if needed.No dependency data recorded yet.