Registry / aws / kinesis-local

kinesis-local

JSON →
library0.5.2jsnpmunverified

kinesis-local provides a mock API for AWS Kinesis, enabling developers to simulate Kinesis data streams for local testing and development environments without incurring AWS costs or requiring an internet connection. The current stable version is 0.5.2, with releases occurring periodically to address bug fixes, update dependencies, and improve underlying infrastructure. It is primarily built on Scala, with recent significant updates including an an overhaul from Scala 2 to Scala 3 and an upgrade to Node.js 25 for its Docker image, introduced in v0.5.0. This tool differentiates itself by offering a fully functional local Kinesis endpoint, allowing for comprehensive integration testing of applications that interact with Kinesis, including producers (KPL) and consumers (KCL), directly on a developer's machine.

npm install kinesis-local
INSTALL
IMPORT
SIG · KINESIS-LOCAL
K
kinesis-local
awsjavascriptv0.5.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.

KinesisClient (AWS SDK v3)
import { KinesisClient, CreateStreamCommand, PutRecordCommand } from '@aws-sdk/client-kinesis'; const kinesisClient = new KinesisClient({ endpoint: 'http://localhost:4568', // Or 'https://localhost:4567' region: 'us-east-1', // Or 'us-west-2' if specified in INITIALIZE_STREAMS credentials: { accessKeyId: 'test', secretAccessKey: 'test' }, tls: false // Only if using HTTP endpoint (4568) });
import Kinesis from 'kinesis-local'; // kinesis-local is an executable service, not a library for direct import.
kinesis-local is a standalone service (an executable server), not a JavaScript library. You interact with it by configuring an AWS SDK Kinesis client to point to its local endpoint (default 4568 for HTTP, 4567 for HTTPS).
Kinesis (AWS SDK v2)
import AWS from 'aws-sdk'; const kinesis = new AWS.Kinesis({ endpoint: 'http://localhost:4568', region: 'us-east-1', accessKeyId: 'test', secretAccessKey: 'test' });
For older projects using AWS SDK v2, configure the Kinesis client similarly, ensuring the `endpoint` is set to the mock's address and dummy credentials are provided, as no actual authentication occurs.
Running the executable (Child Process)
import { exec } from 'child_process'; // In a test setup or CI/CD script, you might run kinesis-local as a child process. const kinesisProcess = exec('npx kinesis-local --port 4568'); kinesisProcess.stdout?.on('data', (data) => console.log(`kinesis-local stdout: ${data}`)); kinesisProcess.stderr?.on('data', (data) => console.error(`kinesis-local stderr: ${data}`)); // ... later, to stop it kinesisProcess.kill();
import { startServer } from 'kinesis-local/main.js'; // Not designed for direct programmatic import and execution as a library; primarily a CLI tool.
While `kinesis-local` bundles a `main.js`, it's intended to be run as a command-line executable via `npx` or Docker. Direct programmatic import of its internal modules is not part of the public API and may be unstable.

Demonstrates how to install and run the `kinesis-local` mock server using `npx`, then configure an AWS SDK v3 Kinesis client to interact with the locally running mock, including initializing a stream and putting a record into it.

import { KinesisClient, CreateStreamCommand, PutRecordCommand } from '@aws-sdk/client-kinesis'; import { exec } from 'child_process'; import { TextEncoder } from 'util'; const encoder = new TextEncoder(); const streamName = 'my-test-stream'; const kinesisLocalPort = 4568; // Default HTTP port async function runKinesisLocalDemo() { // 1. Start kinesis-local in a background process console.log('Starting kinesis-local...'); const kinesisProcess = exec(`npx kinesis-local --port ${kinesisLocalPort} --initialize-streams ${streamName}:1`); kinesisProcess.stdout?.on('data', (data) => console.log(`kinesis-local stdout: ${data}`)); kinesisProcess.stderr?.on('data', (data) => console.error(`kinesis-local stderr: ${data}`)); // Wait a bit for the service to start (in a real app, use a robust health check) await new Promise(resolve => setTimeout(resolve, 5000)); console.log('kinesis-local should be running.'); // 2. Configure AWS SDK Kinesis client to connect to the mock const kinesisClient = new KinesisClient({ endpoint: `http://localhost:${kinesisLocalPort}`, region: 'us-east-1', // Match region specified in --initialize-streams or default credentials: { accessKeyId: 'test', secretAccessKey: 'test' }, // Dummy credentials required tls: false // Disable TLS for local HTTP endpoint }); try { // 3. Put a record into the initialized stream const recordData = encoder.encode(JSON.stringify({ event: 'user_registered', userId: '123' })); console.log(`Putting record to stream: ${streamName}`); const putResult = await kinesisClient.send(new PutRecordCommand({ StreamName: streamName, Data: recordData, PartitionKey: 'user-partition-key-1' })); console.log('Record put successfully:', putResult.SequenceNumber); } catch (error) { console.error('Error interacting with Kinesis Local:', error); } finally { // 4. Clean up: terminate the kinesis-local process console.log('Stopping kinesis-local...'); kinesisProcess.kill(); console.log('kinesis-local stopped.'); } } runKinesisLocalDemo();
Debug
Known issues
breakingVersion 0.5.0 introduced significant internal overhauls, including an upgrade from Scala 2 to Scala 3 and updating the Docker image to use Node.js 25. While the release notes stated 'no usability changes for users,' ensure your execution environment (especially if running via Docker or `main.js` manually) supports these updated runtimes.
fix
Review your Dockerfiles or local Node.js environment to ensure compatibility with Node.js 25 or newer for the `kinesis-local` executable, if not using `npx` directly which handles the environment.
affects: >=0.5.0
gotchakinesis-local uses default ports 4567 for HTTPS and 4568 for HTTP. If these ports are already in use by other services on your machine, `kinesis-local` will fail to start, leading to connection errors from your application.
fix
Either stop the conflicting service or configure `kinesis-local` to use different ports (e.g., `npx kinesis-local --port 8000 --tls-port 8001`) and update your AWS SDK client configuration accordingly.
affects: >=0.1.0
gotchaWhen configuring AWS SDK clients to connect to `kinesis-local`, you must specify a dummy `accessKeyId` and `secretAccessKey` (e.g., 'test'). The mock service does not perform actual authentication, but the SDK requires these fields to be present to construct requests.
fix
Ensure your `KinesisClient` or `AWS.Kinesis` constructor includes `credentials: { accessKeyId: 'test', secretAccessKey: 'test' }` for SDK v3 or `accessKeyId: 'test', secretAccessKey: 'test'` for SDK v2.
affects: >=0.1.0
gotchaWhen using `kinesis-local` with AWS SDK v3, if connecting via the HTTP endpoint (default 4568), you should explicitly set `tls: false` in your `KinesisClient` configuration. This prevents the SDK from attempting a secure connection to an insecure endpoint, which would result in TLS/SSL handshake errors.
fix
Add `tls: false` to your `KinesisClient` configuration object: `new KinesisClient({ endpoint: 'http://localhost:4568', tls: false, ... })`.
affects: >=0.1.0
Errors
Common errors & fixes
connect ECONNREFUSED 127.0.0.1:4568
The `kinesis-local` mock server is not running, has crashed, or is not accessible on the specified port, or there's a firewall blocking the connection.
fix
Verify that `npx kinesis-local` (or your Docker command) is running in a separate terminal without errors. Check for port conflicts, firewall rules, and ensure your AWS SDK client's `endpoint` configuration matches the mock's actual address and port.
InvalidAccessKeyId: The security token included in the request is invalid.
Your AWS SDK client is attempting to authenticate with AWS Kinesis using either no credentials or incorrect credentials for the local mock. The mock does not perform real authentication but requires dummy credentials to be present.
fix
Configure your AWS SDK Kinesis client with dummy credentials: `accessKeyId: 'test', secretAccessKey: 'test'`.
ValidationException: 1 validation error detected: Value null at 'streamName' failed to satisfy constraint: Member must not be null
An operation was attempted on Kinesis (e.g., `PutRecordCommand`) without specifying a valid `StreamName`.
fix
Ensure that `StreamName` is correctly provided and is a non-null string in your AWS SDK Kinesis commands. Also, confirm the stream exists, either by creating it programmatically or via the `INITIALIZE_STREAMS` environment variable/CLI option when starting `kinesis-local`.
Upgrade
Version history
0.5.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources