Repository navigation
read configureWorkflow() without resolving the class workflow - #355
Merged
adenhertog merged 3 commits intoOct 9, 2026
Merged
Conversation
adenhertog
force-pushed
the
issue-354-configure-workflow-without-resolving
branch
2 times, most recently
from
October 8, 2026 02:51
5b12244 to
2d941ae
Compare
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
adenhertog
force-pushed
the
issue-354-configure-workflow-without-resolving
branch
from
October 9, 2026 05:26
2d941ae to
6b13309
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #354
Summary
bus-core reads a class workflow's
configureWorkflow()from an instance created withObject.create(prototype), so the workflow is only resolved (or constructed) to handle a message. bus-nestjs dropsWorkflowResolvedWithoutMessage, which no longer has a case to report.Background
To read a class workflow's mapping,
WorkflowRegistry.getClassWorkflowHandlersresolved the workflow once at registration: from the container with no message, or withnewand no arguments. #352 addedWorkflowResolvedWithoutMessageto bus-nestjs because a request-scoped workflow gotREQUEST === undefinedthen.Problem
Reading the mapping ran the constructor and built the workflow's whole dependency tree with no message. A request-scoped workflow couldn't read
REQUESTin its constructor, and dependencies with side effects in their constructors were created just to read the configuration.Approach
New internal
configureClassWorkflow()(workflow/configure-class-workflow.ts) callsconfigureWorkflow(mapper)onObject.create(WorkflowCtor.prototype). If it throws anything other than the mapper's own errors, it's wrapped in a new exportedWorkflowConfigurationFailed, which names the workflow, keeps the error ascauseand has ahelptext. The registry andtestWorkflow()both use it, so a test fails the same way the bus does.WorkflowMapper.startedBy/whenthrow the newWorkflowMappingInvalidfor a missing message, a handler name that isn't a string, or a lookup without alookupfunction ormapsTostring. Without this, a value read from a field (e.g.lookup: this.byOrderId) would pass startup and then fail every message.configureClassWorkflowwraps the error inWorkflowConfigurationFailed. AconfigureWorkflowdeclared as an arrow function property, which TypeScript allows, fails withWorkflowConfigurationFailedand help that says to make it a method.Function workflows (
defineWorkflow) are unchanged.bus-nestjs (unreleased): removed
WorkflowResolvedWithoutMessageand its catch innestContainer, and edited the pendingnestjs-modulechangeset. The integration test now checks that a request-scoped workflow readingREQUESTin its constructor starts and gets the message.Breaking (minor changeset and a
MIGRATING.mdentry):configureWorkflow()that uses the instance's fields or injected dependencies now finds themundefined. Nothing in the repo or docs does this.WorkflowHandlerFailed, as class handlers already do, rather than failinginitialize(). bus-nestjs still fails at startup through itsintrospectcheck (BusClassNotProvided).Docs: the "Creating a workflow" guide covers how
configureWorkflowis called, and the NestJS guide says request-scoped workflows can readREQUESTin their constructors.This is original work under the clean-room policy, not ported, translated or copied from another messaging framework
Added a changeset (
pnpm changeset) for user-facing changes to published packages, or none is neededDocs: updated
docs/for user-facing changes, or none needed🤖 Generated with Claude Code