Skip to content

Commit 4b6bf52

Browse files
cevianclaude
andcommitted
fix: discover agents/nodes before workflows to prevent duplicate DBOS registration
Workflows import agents via relative paths. When all three discovery functions ran in parallel, the same agent file could be evaluated twice (once by discoverAgents, once as a workflow dependency) before jiti cached it, causing duplicate DBOS.registerWorkflow() calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5c3250a commit 4b6bf52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/src/discover.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ export interface DiscoverResult {
2121
* Returns the exact shape that create0pflow() expects.
2222
*/
2323
export async function discover(projectDir: string): Promise<DiscoverResult> {
24-
const [wfResult, nodeResult, agentResult] = await Promise.all([
25-
discoverWorkflows(projectDir),
24+
// Discover agents and nodes first so they're in jiti's module cache.
25+
// Workflows import agents/nodes, and if loaded in parallel, the same
26+
// agent file gets evaluated twice causing duplicate DBOS registration.
27+
const [nodeResult, agentResult] = await Promise.all([
2628
discoverNodes(projectDir),
2729
discoverAgents(projectDir),
2830
]);
2931

32+
const wfResult = await discoverWorkflows(projectDir);
33+
3034
// Convert workflows array to Record keyed by name
3135
const workflows: Record<string, AnyExecutable> = {};
3236
for (const wf of wfResult.workflows) {

0 commit comments

Comments
 (0)