You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check at startup that the container can resolve every class handler and workflow #356
Since #355, the bus only resolves class workflows from the container to handle a message, as it already does for class handlers. A container that can't resolve a class handler or workflow is now only found when a message arrives. That message then fails with ClassHandlerNotResolved or WorkflowHandlerFailed, is retried, and ends up in the dead letter queue. initialize() doesn't report it. bus-nestjs catches this at startup with its own introspect check (BusClassNotProvided), but other containers have no such check.
Also, without a container, build() throws ContainerNotRegistered for a class handler whose constructor takes arguments (bus-configuration.ts, the !this.container check in build()). Class workflows aren't checked, so a workflow that needs dependencies is constructed with undefined arguments for each message.
Proposal
Add an optional ContainerAdapter.isRegistered?(type): boolean | Promise<boolean>. initialize() calls it, when the adapter has it, for every class handler and class workflow, and throws a named error listing the classes the container can't resolve, with the fix. Each common container has a matching call:
inversify: isBound
tsyringe: isRegistered
awilix: hasRegistration
Nest: introspect or has. bus-nestjs's nestContainer would implement it, and its own startup check could then reuse it.
Extend build()'s ContainerNotRegistered check to class workflows whose constructor has length > 0. Make the error's wording (currently about "class handlers", with a classHandlerName field) cover both handlers and workflows.
The second is breaking for a bus without a container that registers a workflow whose constructor takes arguments, so it ships as minor with a MIGRATING.md entry.
Activity