Skip to content

(nextjs) discover workflows imported from instrumentation.ts #1845

@NathanColosimo

Description

@NathanColosimo

@workflow/next currently discovers workflows from pages, app, src/pages, and src/app, but not from Next’s instrumentation.ts. The Postgres World docs explicitly tell Next users to start the world from instrumentation.ts, which makes it natural to also start singleton or bootstrap workflows there.

For example, I would like to start a repeating 24hr cron on startup via triggering once in instrumentation.ts

Today those workflows are omitted from the manifest and fail at runtime as “not registered”. Expected behavior is that instrumentation.ts and src/instrumentation.ts are treated as supported server discovery entrypoints.

Right now I basically need an extra stub file as workaround where I just import the workflows in a file in src/app called "workflow-registry.ts"

import "server-only";

import "@/workflows/cron1/index";
import "@/workflows/cron2/index";

and then in instrumentation.ts:

await triggerCron1();
await triggerCron2();

Without that workflow-registry file I get that "not registered" error.

Will open PR later to fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions