npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pino-http-transport

v2.0.0

Published

A reliable Pino transport for sending logs to an HTTP endpoint

Readme

pino-http-transport

npm version License: MIT

A Pino transport that sends JSON log batches to an HTTP or HTTPS endpoint. It preserves batch order, retries transient delivery failures, bounds memory use, and drains queued records during shutdown.

Requires Node.js 24 or later.

Install

pnpm add pino-http-transport

Usage

Use it through Pino's worker transport in production:

import pino from 'pino';

const logger = pino({
  transport: {
    target: 'pino-http-transport',
    options: {
      url: 'https://logs.example.com/ingest',
      headers: { authorization: `Bearer ${process.env.LOG_API_TOKEN}` },
    },
  },
});

The endpoint receives an HTTP POST with a JSON array of Pino log objects. A response is successful only when it has a 2xx status.

Received JSON

Each request body is an array containing up to batchSize records. Standard Pino fields and any structured fields supplied to the logger are preserved:

[
  {
    "level": 30,
    "time": 1785182400000,
    "pid": 4127,
    "hostname": "api-01",
    "requestId": "req_01K1ABCDEF",
    "userId": "user_123",
    "msg": "Checkout completed"
  },
  {
    "level": 40,
    "time": 1785182400125,
    "pid": 4127,
    "hostname": "api-01",
    "requestId": "req_01K1ABCDEG",
    "durationMs": 842,
    "msg": "Slow request"
  }
]

Errors logged with logger.error({ err }, message) include Pino's serialized error object:

[
  {
    "level": 50,
    "time": 1785182400250,
    "pid": 4127,
    "hostname": "api-01",
    "err": {
      "type": "Error",
      "message": "Database unavailable",
      "stack": "Error: Database unavailable\n    at updateOrder (file:///app/orders.js:42:11)"
    },
    "orderId": "order_456",
    "msg": "Could not update order"
  }
]

The exact fields depend on your Pino configuration and the structured values passed to each log call.

For direct embedding, import the ESM entry point:

import pino from 'pino';
import httpTransport from 'pino-http-transport';

const logger = pino(
  httpTransport({
    url: 'https://logs.example.com/ingest',
  })
);

Options

interface HttpTransportOptions {
  url: string; // Required HTTP(S) endpoint
  headers?: Record<string, string>; // Content-Type defaults to application/json
  timeout?: number; // Per request, ms; default 2500
  batchSize?: number; // Records per request; default 100
  batchInterval?: number; // Partial-batch delay, ms; default 5000
  maxRetries?: number; // Retries after the initial request; default 2
  retryDelay?: number; // Initial exponential-backoff delay, ms; default 1000
  maxBufferSize?: number; // Waiting records; default 100000
  silent?: boolean; // Suppress diagnostics only; default false
}

url must use http: or https:. Numeric options are validated when the transport is created.

Receiver example

examples/hono-server contains a runnable Hono server that validates incoming batches and prints each record.

Point the transport at http://localhost:3000/logs. See the example's README for configuration and a sample request.

Delivery and shutdown behavior

  • Only one batch is delivered at a time, preserving record order.
  • A full batch sends immediately; a partial batch sends after batchInterval.
  • Network errors, timeouts, and non-2xx responses retry with exponential backoff. The delay is capped at timeout.
  • When retries are exhausted, the failed batch is reported and subsequent queued batches continue. The transport then fails close so Pino can surface the delivery failure.
  • If the waiting queue exceeds maxBufferSize, the oldest waiting records are discarded. The active request is never discarded.
  • Closing Pino's transport drains the active request and every queued partial batch before completion. Do not call process.exit() directly after logging; allow Pino's transport to finish.

For typical service shutdown, stop accepting work, then end the Pino transport through your application's normal logging lifecycle. Pino's worker transport handles the drain on transport.end().

Development

pnpm install --frozen-lockfile
pnpm check

pnpm check validates formatting, linting, JSDoc, and types. CI additionally runs coverage, the production build, and a package dry run.

License

MIT