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

@oribos/background-tasks

v0.9.0

Published

Oribos background-tasks capability package — application-owned background work as task rows: submit → lease → in-process execution → heartbeat → settle, with adopt() re-running orphans and untilIdle() as a package-level wait. In-memory store and lease def

Readme

@oribos/background-tasks

Application-owned background work, coordinated as task rows — the background-tasks capability package. Phase one of background tasks is a recipe and stays one; this package is the phase-two opt-in manager: you submit a handler, a lease decides who runs it, and the settle comes back to you. It is not wired into anything unless you wire it — the core is untouched (there is no core here at all: the types are self-contained, no @oribos/core peer), and with no heartbeatMs configured the package holds zero timers.

import { createBackgroundTasks } from '@oribos/background-tasks';

const tasks = createBackgroundTasks({
  onSettle: (record) => {
    // The settled record is your protocol: route it — e.g. `sendSignal` it to its thread.
  },
});

const record = await tasks.submit({
  payload: { kind: 'revenue' },
  run: async (payload) => ({ url: `https://reports.example/${payload.kind}` }),
});
// record.status === 'accepted' — the handler runs in-process; the row flips running → done.

await tasks.untilIdle(); // resolves when every task this manager holds has settled
await tasks.get(record.id); // the row: status, result, attempt, settledAt
await tasks.adopt(); // the orphan sweep: rows still running whose lease is free

How it works

  • Rows. submit writes a TaskRecord — { id, status, payload, result?, error?, attempt, createdAt, settledAt? }, JSON-only — through a TaskStore. createInMemoryTaskStore() is the zero-dependency default (deep-copied at the boundary); persistence is the deployment's to write.
  • The lease decides. A row executes only under its lease: submit acquires, the row flips running, the handler runs, the settle releases. The port is acquire(key, ttlMs) → LeaseHandle | null with { token, renew, release } — structurally the same shape as @oribos/distributed-signals' SignalLease (one concept, two domains, zero dependency edge). createInMemoryLeaseStore() is the default; createRedisLease(client) rides the set(NX/PX) / eval structural subset.
  • The settle. done (result) or failed (error message) is written back, the lease is released, and onSettle(record) is awaited — the join to your own reactions, the phase-one recipe in one line: map the record to its thread and sendSignal.
  • The orphan sweep. adopt() re-runs rows still running whose lease this process can take — attempt + 1, at-least-once, idempotency the application's (the @oribos/checkpoints recover caliber). A row whose lease is still held, or for which this process holds no handler, is left alone: v1 executes handlers in-process, so adopting across a restart is app-level hand-off, not this call.
  • untilIdle(). A package-level wait: resolves when every task this manager is holding has settled (idle resolves at once). It does not touch the agent's stream.
  • Heartbeat. Configured heartbeatMs: a renewal interval runs while a handler executes, and the acquire/renew TTL is 3 × heartbeatMs (the documented expiry window: two missed beats). Absent: zero timers — the TTL is a fixed 30 s, so handlers that may run longer configure it.

The documented windows and v1 refusals

  • A handler that outlives its lease (no heartbeat: past 30 s) can be taken over by an adopt() racer — at-least-once by design; make handlers idempotent, and use attempt to see re-runs.
  • v1 refuses: retry / backoff policy (the deployment's), priorities and concurrency control, resident workers / cross-process handler execution, structured result storage beyond the JSON payload, and any overlap with cron / schedules.

The example

examples/background-tasks runs five acts offline: the phase-one recipe verbatim (tool acks, own worker reports, framework holds nothing), then the manager driving the same recipe (onSettle → sendSignal) and an orphan adopted and re-run. It is wired into the repo's example gate.