Every example is one small application written twice: -vanilla and -canc. Same files, same
function names, same order, so the two versions are meant to be read as a diff. The vanilla side
is not a strawman. Where cancellation is the point of the example, it carries the real
AbortController attempt with its guards and cleanup, and the comparison is against that.
The app-* projects integrate with a framework, a server or a library. The demo-* projects are
smaller and each teaches one part of the ecosystem.
The examples consume the built dist of each package through npm file: dependencies, and this
directory is a separate npm project, so it installs on its own.
# in the monorepo root
npm install
npm run build
# here
cd examples
npm installThen run either flavor of an example:
cd demo-promise-basics
npm run start:vanilla
npm run start:cancFrontend examples add dev:vanilla and dev:canc for a dev server with hot reload, and
build:vanilla / build:canc for a production build.
Everything at once, from the monorepo root:
npm run examples:test
npm run examples:typecheckEach example has its own README with the file map, what to diff, and an honesty note about which layer cancellation actually reaches. For why the disconnect examples do not just read the platform's own request signal, see the honesty note in app-express-kysely.
- app-react travel search typeahead. Every keystroke cancels the previous search, so a slow response cannot overwrite a newer one. Hover prefetch cancels on unhover.
- app-react-suspense destination details under Suspense. A cancelable boundary aborts the load the user walked away from.
- app-react-zustand album and track browser. Switching albums fast cancels the store action still in flight.
- app-vue marketplace catalog. A cancelable watch cancels the previous run before starting the next, which is the awaited-watch footgun in plain Vue.
- app-vue-pinia checkout wizard. Leaving a step cancels the calls that step started.
- app-vue-suspense product page under
<Suspense>, cancellation on scope teardown.
- app-angular orders admin with a detail pane. The same service is built twice, one
with the coroutine decorator and one wiring
canc.asyncby hand.
- app-express-kysely slow report endpoint over PGlite. Cancellation is threaded into Kysely through one helper, with an opt-in pg path for real wire-cancel.
- app-fastify-mongoose hotel availability search. The route handler is a coroutine, the repository is cancelified, so no signal is threaded through the service.
- app-fullstack-cancel user search across a React client, Express route, and MikroORM over PGlite. Cancel aborts the HTTP request and stops database queries.
- app-nestjs-typeorm invoicing API. An interceptor cancels the request scope,
and a bulk endpoint rolls its transaction back in a shielded
finally.
- app-ai-chat-stop support chat with a Stop button that stops the spend, across browser, server and the model call.
- app-ai-rag-pipeline retrieval pipeline (embed, retrieve, rerank, stream) as one cancelable flow. No API key needed.
- app-fetch-streaming paginated activity feed streaming. Stopping early aborts the in-flight page fetch and halts pagination.
- app-ws-progress video export progress over a WebSocket. Cancel stops the transcode, not just the progress bar.
- app-axios an axios instance whose request methods return cancelable promises, against the manual request registry it replaces.
- app-rxjs log viewer where an observable stream drives promise-based work.
switchMapalone does not stop it, and this is what does.
- app-cli-graceful site backup CLI. Ctrl-C cancels the whole task tree gracefully, a second one exits immediately.
- app-crawler-race site health crawl through a concurrency pool. One cancel prunes the entire in-flight subtree.
- demo-promise-basics cancellation as a rejection, cancel handlers, and the
two-way propagation an
AbortControllercannot express. - demo-chain-propagation propagation down and bubbling up, with
bubble: falseandshield: truein context. - demo-combinators what
all,any,raceandallSettleddo to the losers. - demo-coroutine
canc.asyncandcanc.awaitthrough a checkout flow, including an acknowledged cancellation gap. - demo-fetch cancelable requests, external signals, pre-aborted signals, timeout composition.
- demo-toolbox pollers, retries, delays and timeouts under cancellation.
- demo-decorators one client class wired four ways, one per decorator dialect plus the manual form.
- demo-signal-interop bridges in both directions between signals and cancelable promises.
- demo-async-dispose
await usingscopes, cleanup ordering, shield survival, disposal after settle. - demo-async-iter stream transforms with async iterator pipe operators and cancel propagation back to the source generator.
Packages under _shared/ are internal to the examples and are never published. The @shared
scope reads like a path alias and resolves through the normal workspace symlink.
@shared/mock-apifake domain APIs that log their calls, including anabortedmarker so an example can prove a request was really stopped@shared/utilsmall cross-example helpers such assleep
Code under an example's src/lib/ is written to be copied. It is general-purpose enough to be
extracted into a package later, so treat it as a starting point for your own hooks, composables
and adapters.
Most canc entry points also import @cancjs/unhandled-rejection/register at the top of main-canc,
an app-wide guard that ignores CancelError and lets real rejections surface. Entries that already
handle cancellation explicitly with their own isCancelError check skip the import, since the
explicit handling is the point being demonstrated.