Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

The SWC compiler was transforming step functions in client mode to call runStep(), a stubbed function that throws errors. This prevented direct step function calls outside workflows, contradicting the documented behavior.

Changes

  • SWC transform (packages/swc-plugin-workflow/transform/src/lib.rs)

    • Step functions in TransformMode::Client now only have their directive removed, preserving the original function body
    • Removed client-mode import generation for runStep
    • Cleaned up three unused transformation helper functions
  • Fixture tests

    • Updated all output-client.js files via UPDATE=1 to reflect unchanged step implementations
  • New E2E test

Before

// Client mode output
import { runStep as __private_run_step } from "workflow/api";
export async function processData(data) {
    return __private_run_step("processData", { arguments: [data] });
}

After

// Client mode output - directive removed, implementation intact
export async function processData(data) {
    const result = someHelper(data);
    const transformed = anotherHelper(result);
    return defaultExport(transformed);
}
Original prompt

in the SWC compiler right now,I think we transform the step function definitions in “client mode” to use “runStep” from “workflow/internal/private” but that function is just stubbed to throw an error. in reality we shouldn’t transform the step function in client mode. this way, calling steps directly outside of a workflow will also "just work" like its meant to (and as we say in the docs)

Let's change the compiler to not transform the step in client mode (it should just remove the directive) and update the fixture tests (using UPDATE=1 when rynning them). Additionally, add a test to the core package that ensures that calling a step outside a workflow works as expected :)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2025

🦋 Changeset detected

Latest commit: f19e847

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

This PR includes changesets to release 10 packages
Name Type
@workflow/swc-plugin Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/sveltekit Patch
workflow Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/ai 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

@vercel
Copy link
Contributor

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 8, 2025 3:05am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 8, 2025 3:05am
example-workflow Ready Ready Preview Comment Nov 8, 2025 3:05am
workbench-nitro-workflow Ready Ready Preview Comment Nov 8, 2025 3:05am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 8, 2025 3:05am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 8, 2025 3:05am
workbench-vite-workflow Ready Ready Preview Comment Nov 8, 2025 3:05am
workflow-docs Ready Ready Preview Comment Nov 8, 2025 3:05am

Copilot AI changed the title [WIP] Remove step function transformation in client mode Remove step function transformation in client mode Nov 7, 2025
Copilot AI requested a review from pranaygp November 7, 2025 23:57
Copilot finished work on behalf of pranaygp November 7, 2025 23:57
Copy link
Member

@VaguelySerious VaguelySerious left a comment

Choose a reason for hiding this comment

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

LGTM - I see the API endpoint isn't being added to to Hono / Nitro v1/v2, but I guess that's fine since we don't run e2e tests against them yet

@VaguelySerious VaguelySerious merged commit 4f9ae4e into main Nov 8, 2025
34 of 35 checks passed
@VaguelySerious VaguelySerious deleted the copilot/remove-step-transform-client-mode branch November 8, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants