CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-wait-on

Cross-platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

wait-on

wait-on is a cross-platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available. It provides both a command line interface and programmatic Node.js API with extensive configuration options for monitoring various resource types with customizable timeouts, intervals, and retry logic.

Package Information

  • Package Name: wait-on
  • Package Type: npm
  • Language: JavaScript (CommonJS)
  • Installation: npm install wait-on
  • Node.js Version: 12.0.0+

Core Imports

const waitOn = require('wait-on');

For ES modules:

import waitOn from 'wait-on';

Basic Usage

const waitOn = require('wait-on');

// Simple file waiting
await waitOn({ resources: ['file:/path/to/file'] });

// Wait for HTTP endpoints
await waitOn({ 
  resources: ['http://localhost:3000', 'https://api.example.com/health'] 
});

// Wait for multiple resource types
await waitOn({
  resources: [
    'file:/tmp/app.log',
    'tcp:localhost:3000',
    'http://localhost:3000/health'
  ],
  timeout: 30000,
  interval: 1000
});

// Using callback style
waitOn({
  resources: ['http://localhost:8080']
}, (err) => {
  if (err) {
    console.error('Resource failed to become available:', err);
  } else {
    console.log('Resources are now available!');
  }
});

Architecture

wait-on is built around several key components:

  • Resource Monitoring: Supports file, HTTP/HTTPS, TCP port, and Unix socket monitoring
  • Observable Streams: Uses RxJS for reactive resource polling and state management
  • Timeout Management: Configurable timeout handling with detailed error reporting
  • Cross-platform: Runs on Linux, Unix, macOS, and Windows
  • Reverse Mode: Can wait for resources to become unavailable
  • CLI Interface: Command-line wrapper with full feature parity

Capabilities

Node.js API

Core programmatic interface for waiting on resources with Promise and callback support. Includes comprehensive configuration options for timeouts, intervals, and HTTP-specific settings.

/**
 * Wait for resources to become available
 * @param opts - Configuration options
 * @param cb - Optional callback function (err) => void
 * @returns Promise<void> when cb not provided
 */
function waitOn(opts, cb?): Promise<void> | void;

Node.js API

Command Line Interface

Command-line utility with full access to all wait-on functionality through CLI arguments and configuration files. Supports time interval parsing and environment-specific options.

wait-on [options] resource1 [resource2 ...]

Command Line Interface

Resource Types

Support for multiple resource types including files, HTTP endpoints, TCP ports, and Unix domain sockets. Each resource type has specific behavior and configuration options.

// File resources (default)
'file:/path/to/file'
'/path/to/file'

// HTTP resources  
'http://hostname:port/path'
'https://hostname:port/path'
'http-get://hostname:port/path'
'https-get://hostname:port/path'

// TCP port resources
'tcp:hostname:port'
'tcp:port'  // defaults to localhost

// Unix socket resources
'socket:/path/to/socket'

// HTTP over Unix socket
'http://unix:/path/to/socket:/url/path'
'http-get://unix:/path/to/socket:/url/path'

Resource Types

Types

interface WaitOnOptions {
  resources: string[];
  delay?: number;
  httpTimeout?: number;
  interval?: number;
  log?: boolean;
  reverse?: boolean;
  simultaneous?: number;
  timeout?: number;
  validateStatus?: (status: number) => boolean;
  verbose?: boolean;
  window?: number;
  tcpTimeout?: number;
  
  // HTTP/HTTPS options
  ca?: string | Buffer | (string | Buffer)[];
  cert?: string | Buffer | (string | Buffer)[];
  key?: string | Buffer | object | (string | Buffer | object)[];
  passphrase?: string;
  proxy?: boolean | {
    host: string;
    port: number;
    auth?: {
      username: string;
      password: string;
    };
  };
  auth?: {
    username: string;
    password: string;
  };
  strictSSL?: boolean;
  followRedirect?: boolean;
  headers?: object;
}

docs

api.md

cli.md

index.md

resources.md

tile.json