Skip to content

Fixes for workflow serde on latest 'workflow' package#70

Open
TooTallNate wants to merge 1 commit intoworkflow-serdefrom
workflow-serde-nate
Open

Fixes for workflow serde on latest 'workflow' package#70
TooTallNate wants to merge 1 commit intoworkflow-serdefrom
workflow-serde-nate

Conversation

@TooTallNate
Copy link

No description provided.

Copilot AI review requested due to automatic review settings January 31, 2026 00:03
@vercel
Copy link

vercel bot commented Jan 31, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
just-bash Ignored Ignored Jan 31, 2026 0:03am

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for workflow serialization/deserialization on the latest '@workflow/serde' package. It enables Bash instances to be serialized and passed between workflow steps while maintaining filesystem state.

Changes:

  • Added workflow export condition with opaque handle classes (BashHandle, InMemoryFsHandle) that provide stub implementations for type compatibility during workflow discovery
  • Implemented Bash.from() static method for rehydrating Bash instances from serialized state without invoking the constructor
  • Updated build configuration to bundle workflow entry point and removed minification flags

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/workflow.ts New entry point exporting opaque handle classes for workflow environments
src/BashHandle.ts Opaque handle for Bash class with stub methods that throw errors
src/InMemoryFsHandle.ts Opaque handle for InMemoryFs class with stub methods that throw errors
src/Bash.ts Added Bash.from() static method and updated WORKFLOW_DESERIALIZE to use it
package.json Added workflow export condition, updated build scripts, upgraded pnpm version
knip.json Added new entry points for code coverage analysis
examples/workflow-vite/workflows/bash-workflow.ts Example demonstrating workflow usage with debug statements
examples/workflow-vite/vite.config.ts Added rollup config to externalize native modules
examples/workflow-vite/pnpm-workspace.yaml Added local workflow package override (development only)
examples/workflow-vite/package.json Updated workflow package URL
pnpm-lock.yaml Dependency updates including lockfile format v9 and package version bumps

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Step 1: Create bash instance and initialize
let bash = await createBash();
console.log(bash);
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Debug console.log statements have been left in the workflow example code. These should be removed before merging as they add unnecessary noise to production workflows.

Copilot uses AI. Check for mistakes.
async function createBash() {
"use step";
console.log(Bash);
console.log((Bash as any).classId);
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Debug console.log statements accessing internal classId property should be removed before merging. These appear to be development debugging code.

Suggested change
console.log((Bash as any).classId);

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
overrides:
workflow: link:../../../../vercel/workflow/packages/workflow
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The pnpm-workspace.yaml file contains an override that links to a local path ../../../../vercel/workflow/packages/workflow, which is specific to a local development environment. This will break for other developers and in CI/CD. The override should either be removed or documented as a local development-only configuration that should not be committed.

Suggested change
overrides:
workflow: link:../../../../vercel/workflow/packages/workflow
# Local development-only override.
# Do not commit this as an active override, since the path is specific to a
# local monorepo layout and will break for other developers and in CI/CD.
# Uncomment and adjust the path as needed for local testing:
# overrides:
# workflow: link:../../../../vercel/workflow/packages/workflow

Copilot uses AI. Check for mistakes.
},
): Bash {
// Create instance without calling constructor
const bash = Object.create(Bash.prototype) as Bash;
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Inconsistency with the main Bash class implementation. In src/Bash.ts line 367, the code uses Object.create(this.prototype) with a comment explaining it handles bundler class renaming. However, this handle class uses Object.create(Bash.prototype) directly at line 294. For consistency and to handle bundler renaming properly, this should also use this.prototype like the real Bash class does.

Suggested change
const bash = Object.create(Bash.prototype) as Bash;
const bash = Object.create(this.prototype) as Bash;

Copilot uses AI. Check for mistakes.
state: InterpreterState;
limits: Required<ExecutionLimits>;
}) {
return Bash.from(serialized);
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Inconsistency with the main Bash class implementation. In src/Bash.ts line 423, the WORKFLOW_DESERIALIZE method uses this.from() instead of Bash.from() to handle bundler class renaming. However, this handle class uses Bash.from(serialized) directly. For consistency and to handle bundler renaming properly, this should also use this.from(serialized) like the real Bash class does.

Suggested change
return Bash.from(serialized);
return this.from(serialized);

Copilot uses AI. Check for mistakes.
Comment on lines +286 to +291
_options?: {
network?: NetworkConfig;
sleep?: (ms: number) => Promise<void>;
trace?: TraceCallback;
logger?: BashLogger;
},
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The BashHandle.from() method accepts options for network, sleep, trace, and logger (lines 286-291), but these options are prefixed with underscore and never used in the implementation (lines 301-305). This could be misleading to users who might expect these options to have some effect. If these options are intentionally ignored in the handle, the parameter name should be _options instead of having individual properties, or the JSDoc should clearly state that these options are accepted for API compatibility but have no effect in the handle.

Copilot uses AI. Check for mistakes.
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:pyodide && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js",
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify-syntax --minify-whitespace --keep-names --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs && echo 'var _Bash=Bash,_InMemoryFs=InMemoryFs;' >> dist/bundle/index.js",
"build:lib": "esbuild dist/index.js dist/workflow.js --bundle --splitting --platform=node --format=esm --keep-names --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The build script has been modified to remove the minification flags --minify-syntax and --minify-whitespace, and also removes a line that was appended to the output. These changes mean the bundled code will be larger and potentially expose internal implementation details. If this is intentional for debugging workflow issues, it should be documented. Otherwise, minification should be restored for production builds.

Suggested change
"build:lib": "esbuild dist/index.js dist/workflow.js --bundle --splitting --platform=node --format=esm --keep-names --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
"build:lib": "esbuild dist/index.js dist/workflow.js --bundle --splitting --platform=node --format=esm --minify-syntax --minify-whitespace --keep-names --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",

Copilot uses AI. Check for mistakes.
},
): Bash {
// Create instance without calling constructor
const bash = Object.create(Bash.prototype) as Bash;
Copy link

Choose a reason for hiding this comment

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

BashHandle.ts uses hardcoded Bash.prototype and Bash.from() instead of this.prototype and this.from(), causing incorrect prototype assignment when bundlers rename the class.

Fix on Vercel

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.

1 participant