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

@conduit-client/service-renewable-resource-manager

v3.23.1

Published

Generic renewable-resource manager service (lazy cache + single-flight fetch + refresh-storm dedup)

Readme

@conduit-client/service-renewable-resource-manager

A generic, pluggable service for managing a single renewable resource — a value you fetch, cache, hand out on demand, and re-fetch when it goes stale. CSRF tokens are the first consumer; SFAP JWTs and other renewable credentials fit the same shape.

See the design rationale in adrs/2026-05-13-renewable-resource-manager-as-service.md.

What it is

  • Lazy & externally-triggered. No TTL, no expiry tracking, no autonomous renewal. It fetches on first get() and re-fetches only when a caller invokes refresh(). "Renewable" describes the resource (it can be re-fetched), not a behavior of the manager.
  • Single-flight. Concurrent get()/refresh() calls share one in-flight fetch.
  • Refresh-storm bounded. When many callers fail against the same stale value at once, refresh(staleValue) collapses them to a single network round-trip (see below).

Usage

import {
  BasicRenewableResourceManager,
  buildRenewableResourceManagerDescriptor,
} from '@conduit-client/service-renewable-resource-manager/v1';

const manager = new BasicRenewableResourceManager<string>({
  fetch: () => fetchTokenFromServer(), // "go to the network"
  storage: {
    get: () => durableStorage.get(KEY),
    set: (v) => durableStorage.set(KEY, v),
    clear: () => durableStorage.remove(KEY),
  },
});

// register as a named, versioned service
const descriptor = buildRenewableResourceManagerDescriptor('csrfToken', manager);

API

RenewableResourceManager<T extends string | number | boolean>

  • get(): PromiseLike<T | undefined> — cached value, or fetch+cache if empty.
  • refresh(staleValue?: T): PromiseLike<T | undefined> — fetch fresh, overwrite cache. With staleValue, short-circuits if storage already moved past it.
  • clear(): PromiseLike<void> — discard the cache (logout, org switch, teardown). Routine staleness uses refresh, which is non-destructive.

T is constrained to primitives so the storm-dedup comparison can use ===.

Error contract

  • A rejected PromiseLike ⇒ the fetch could not complete (network/server error). Rejections propagate; they are never swallowed into undefined.
  • A resolved undefined ⇒ the fetch completed and there is genuinely no value. The cache is not cleared in this case — use clear() for that.

Refresh-storm dedup, by timing regime

  1. Concurrent failures (arriving while a fetch is in flight) share that fetch via single-flight.
  2. Late failures (arriving after the first refresh stored a fresh value) are caught by refresh(staleValue): storage no longer holds staleValue, so the stored value is returned with no network hop.

Storage adapter preconditions

The manager relies on (but cannot enforce):

  • writes are durable before the returned PromiseLike resolves;
  • reads observe the most recent settled write (read-your-writes);
  • the manager is the sole writer of the slot, and replacement is monotonic — the storm-dedup treats "stored differs from stale" as "someone refreshed."