Registry / http-networking / autocannon

autocannon

JSON →
library8.0.0jsnpmunverified

An HTTP/1.1 benchmarking tool for Node.js, designed to be fast and easy to use. Current stable version is 8.0.0, released in late 2021. It supports HTTP pipelining, HTTPS, and can produce more load than wrk or wrk2. It offers both a command-line interface and a programmatic API, with features like warm-up, worker threads, HAR file replay, and custom request bodies. The project is actively maintained by the Node.js community.

npm install autocannon
INSTALL
IMPORT
SIG · AUTOCANNON
A
autocannon
http-networkingjavascriptv8.0.0
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 autocannon from 'autocannon'
const autocannon = require('autocannon')
ESM-only since v8; CJS deprecation warning since v7.
autocannon.track
import autocannon from 'autocannon'; autocannon.track(instance)
import { track } from 'autocannon'; track(instance)
track is a static method on the default export, not a named export.
Result type
import autocannon from 'autocannon'; const result: autocannon.Result = ...
import { Result } from 'autocannon'
Result is exported as a type via the default export's namespace, not a named export.

Runs a 10-second benchmark with 10 concurrent connections against a local server and prints progress to console.

import autocannon from 'autocannon'; const instance = autocannon({ url: 'http://localhost:3000', connections: 10, duration: 10, }, (err, result) => { if (err) { console.error(err); return; } console.log(result); }); autocannon.track(instance);
autocannon --version
Debug
Known issues
breakingautocannon v8 dropped CommonJS support; requires ESM imports.
fix
Update imports to use ESM syntax; do not use require().
affects: >=8.0.0
deprecatedThe 'printResult' function is deprecated in favor of 'autocannon.print'. In v8, 'printResult' may be removed.
fix
Replace autocannon.printResult(output, result) with autocannon.print(output, result).
affects: >=7.0.0
gotchaWhen using '--workers', the callback in the programmatic API is not called; results are only available via track or event listeners.
fix
Use autocannon.track() or listen for 'done' event on the instance.
affects: *
gotchaSetting both 'amount' and 'duration' will cause 'duration' to be ignored.
fix
Use only one of 'amount' or 'duration' at a time.
affects: *
gotchaWhen using a custom 'requestIterator', the 'requests' option inside the iterator must be an array of objects with 'method', 'path', etc., not just strings.
fix
Ensure the 'requests' array contains objects with 'method', 'path', 'headers', 'body' as needed.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/autocannon/index.js from /path/to/your.js not supported.
Using require() to import autocannon v8 which is ESM-only.
fix
Replace require('autocannon') with import autocannon from 'autocannon' or use dynamic import().
autocannon is not a function
Importing autocannon incorrectly; e.g., importing named export instead of default.
fix
Use import autocannon from 'autocannon' (default import).
connect ECONNREFUSED 127.0.0.1:3000
Target server is not running or port is wrong.
fix
Ensure the server is running on the specified port; check URL and port.
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
node-gyp-buildoptionalRequired for building native addons (ReusePort).
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
autocannon — npm install autocannon · libregistry