@matrixai/async-init has grown beyond "async init decorators".
It is effectively a lifecycle kernel for long-running, resourceful, asynchronous service objects.
This issue is to do the v3 refactor intentionally, instead of continuing to extend the current decorator-first model.
The result should stay constrained to just 2 repos for now:
@matrixai/async-init - js-async-init
@matrixai/container - js-container
No extra package splitting yet. Any runtime-specific integrations should stay inside these repos as adapters/subpath exports.
Why
The current library is doing multiple jobs at once:
- lifecycle state management
- concurrent transition control
- runtime method admission (
@ready)
- error policy
- events/tracing hooks
It also duplicates the same core machinery across:
CreateDestroy
StartStop
CreateDestroyStartStop
Conceptually, this is no longer just "async init". It is a reusable lifecycle model for invisible service objects in JS runtimes.
That is useful not only in Node/CLI, but also in browser, worker, scene/runtime, transport, and WASM-adjacent code.
Goal
Refactor @matrixai/async-init into a clean lifecycle kernel that:
- preserves the original lifecycle motivations
- supports modern TS/ESM/runtime assumptions
- remains usable in backend and frontend environments
- stops treating decorators as the architectural center
- leaves graph wiring and lazy dependency planning to
js-container
Non-goals
This issue is not about:
- turning
@matrixai/async-init into a full IoC framework
- turning it into a full actor/process runtime
- adding many more repos/packages
- replacing React/component lifecycle
- rebuilding the world before landing v3
High-level direction
@matrixai/async-init
Owns:
- lifecycle state machine
- transition orchestration
- operation admission
- ownership/disposal semantics
- lifecycle events / tracing hooks
- compatibility decorators
- runtime adapters in the same repo
@matrixai/container
Owns:
- service tokens/providers
- scopes
- overrides
- lazy dependency edges
- boot/shutdown ordering
Core refactor principles
- Replace the 3 duplicated lifecycle implementations with 1 internal lifecycle engine.
- Treat
CreateDestroy, StartStop, and CreateDestroyStartStop as profiles over that engine.
- Replace error-instance APIs with error classes/factories/options.
- Remove stack-reset magic as part of the breaking change.
- Keep decorators as compatibility sugar, not the core abstraction.
- Keep runtime adapters in the same repo via subpath exports.
- Keep
js-container as the only companion repo for graph wiring.
Expected outcome
After this work, @matrixai/async-init should feel like a small, dependable substrate for invisible async services in JS, rather than a strange decorator package that happens to encode runtime semantics.
@matrixai/async-inithas grown beyond "async init decorators".It is effectively a lifecycle kernel for long-running, resourceful, asynchronous service objects.
This issue is to do the v3 refactor intentionally, instead of continuing to extend the current decorator-first model.
The result should stay constrained to just 2 repos for now:
@matrixai/async-init- js-async-init@matrixai/container- js-containerNo extra package splitting yet. Any runtime-specific integrations should stay inside these repos as adapters/subpath exports.
Why
The current library is doing multiple jobs at once:
@ready)It also duplicates the same core machinery across:
CreateDestroyStartStopCreateDestroyStartStopConceptually, this is no longer just "async init". It is a reusable lifecycle model for invisible service objects in JS runtimes.
That is useful not only in Node/CLI, but also in browser, worker, scene/runtime, transport, and WASM-adjacent code.
Goal
Refactor
@matrixai/async-initinto a clean lifecycle kernel that:js-containerNon-goals
This issue is not about:
@matrixai/async-initinto a full IoC frameworkHigh-level direction
@matrixai/async-initOwns:
@matrixai/containerOwns:
Core refactor principles
CreateDestroy,StartStop, andCreateDestroyStartStopas profiles over that engine.js-containeras the only companion repo for graph wiring.Expected outcome
After this work,
@matrixai/async-initshould feel like a small, dependable substrate for invisible async services in JS, rather than a strange decorator package that happens to encode runtime semantics.