Skip to main content

Node.js SDK

The Node.js SDK for writing TaskDaemon handlers.

Installation

Install the published npm package from your handler application’s directory:
For TypeScript, also install the compiler and Node.js types:
Commit the generated package-lock.json and include it with package.json in the Docker build context. The Dockerfiles below use the registry dependency and install from this lockfile. For a local source build from the same release:
For a source-based Docker build, copy this archive into the same vendor path before running npm ci. Keep diagnostic logs on stderr; the handler protocol uses stdout for one response per task. A request starts with attempt: 1; retries require a valid retryable error and remaining stored budget.

Basic Usage

Task Interface

Return Types

The SDK provides helper functions for creating results:
Or construct the result object directly:

Async Handlers

Handlers can be async. Install axios for this example:

Complete Example

Install sharp and axios, and use a TypeScript build configured for Node and default imports (for example esModuleInterop: true):

Error Handling

Uncaught exceptions are automatically converted to non-retryable errors:

Dockerfile

Or for JavaScript:

Handler Configuration