Fixes for workflow serde on latest 'workflow' package#70
Fixes for workflow serde on latest 'workflow' package#70TooTallNate wants to merge 1 commit intoworkflow-serdefrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
| async function createBash() { | ||
| "use step"; | ||
| console.log(Bash); | ||
| console.log((Bash as any).classId); |
There was a problem hiding this comment.
Debug console.log statements accessing internal classId property should be removed before merging. These appear to be development debugging code.
| console.log((Bash as any).classId); |
| overrides: | ||
| workflow: link:../../../../vercel/workflow/packages/workflow |
There was a problem hiding this comment.
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.
| 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 |
| }, | ||
| ): Bash { | ||
| // Create instance without calling constructor | ||
| const bash = Object.create(Bash.prototype) as Bash; |
There was a problem hiding this comment.
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.
| const bash = Object.create(Bash.prototype) as Bash; | |
| const bash = Object.create(this.prototype) as Bash; |
| state: InterpreterState; | ||
| limits: Required<ExecutionLimits>; | ||
| }) { | ||
| return Bash.from(serialized); |
There was a problem hiding this comment.
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.
| return Bash.from(serialized); | |
| return this.from(serialized); |
| _options?: { | ||
| network?: NetworkConfig; | ||
| sleep?: (ms: number) => Promise<void>; | ||
| trace?: TraceCallback; | ||
| logger?: BashLogger; | ||
| }, |
There was a problem hiding this comment.
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.
| "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", |
There was a problem hiding this comment.
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.
| "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", |
No description provided.