Skip to content

[miniflare] Add workflow introspection for exported Workflows - #17016

Open
edmundhung wants to merge 2 commits into
mainfrom
edmundhung/miniflare-introspect-exported-workflows
Open

edmundhung wants to merge 2 commits into
mainfrom
edmundhung/miniflare-introspect-exported-workflows

Conversation

@edmundhung

Copy link
Copy Markdown
Member

Part of RM-31812. The cf test harness (#16798) is stacked on this.

Adds unsafeIntrospectWorkflow(workerName, className) and unsafeIntrospectWorkflowInstance(workerName, className, instanceId), so Node.js code can introspect a Workflow that a Worker exports, including one only on ctx.exports, without an env binding. Introspection through a binding, as in the Vitest plugin, is unchanged.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: these are unsafe Miniflare methods for the cf test harness

@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7920aae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
miniflare Minor
@cloudflare/deploy-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@17016

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@17016

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@17016

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@17016

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@17016

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@17016

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@17016

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@17016

miniflare

npm i https://pkg.pr.new/miniflare@17016

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@17016

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@17016

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@17016

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@17016

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@17016

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@17016

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@17016

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@17016

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@17016

wrangler

npm i https://pkg.pr.new/wrangler@17016

commit: 7920aae

@edmundhung edmundhung changed the title [miniflare] Add unsafeIntrospectWorkflow() for exported Workflows [miniflare] Add workflow introspection for exported Workflows Nov 18, 2026
if (workflowIntrospectionSessions.has(this.env.WORKFLOW_NAME)) {
throw new Error(
`Workflow ${JSON.stringify(this.env.WORKFLOW_NAME)} already has an active introspection session for binding ${JSON.stringify(this.env.BINDING_NAME)}.`
`Workflow ${JSON.stringify(this.env.WORKFLOW_NAME)} already has an active introspection session.`

@edmundhung edmundhung Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping the binding name here as an introspection session is started per workflow instead of per binding. It would also be confusing as more users adopts exports which might not have an binding anymore.

@edmundhung
edmundhung marked this pull request as ready for review November 19, 2026 11:21
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team November 19, 2026 11:21
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/workflows
  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/introspect-exported-workflows.md: [@cloudflare/wrangler]
  • .changeset/workflow-introspection-session-error.md: [@cloudflare/wrangler]
  • packages/miniflare/src/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/plugins/workflows/exports.spec.ts: [@cloudflare/wrangler]
  • packages/workflows-shared/src/binding.ts: [@cloudflare/workflows @cloudflare/wrangler]
  • packages/wrangler/e2e/createTestHarness.test.ts: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 7920aaed.

This review, of 161ab5dd

✅ Approved — No issues found. The new exported-Workflow introspection methods are small and checked against the Worker's exports, and they come with tests.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No issues found.


📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No issues found.


📝 Documentation: ✅ LGTM

No issues found.


Reviewed commit: 161ab5dd

…owInstance() for exported Workflows

Node.js could only introspect a Workflow through an `env` binding from
getBindings(), so a Workflow only on `ctx.exports` couldn't be introspected.
Each exported Workflow now has a proxy binding, found by its Worker and class
name.
@edmundhung
edmundhung force-pushed the edmundhung/miniflare-introspect-exported-workflows branch from 161ab5d to 7920aae Compare November 19, 2026 12:49

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — No issues found. The new exported-Workflow introspection methods are small and checked against the Worker's exports, and they come with tests.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No issues found.


📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No issues found.


📝 Documentation: ✅ LGTM

No issues found.


Reviewed commit: 7920aaed — same changes as 161ab5dd, so this is that commit's review (no new review was run; line numbers are as of 161ab5dd)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants