-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Description
Summary
After installing the PR #373 fix (related to #367), we encounter a new error when executing workflows in Local World:
Error: Cannot find module 'local'
Require stack:
- /home/waldhari/software-packages/waltoria/apps/advisor-activity-nexus/index.js
at module evaluation (app/api/workflows/trigger/[workflowName]/route.ts:16:1)
> 16 | import { start } from 'workflow/api'
Background
- Original Issue: ReferenceError: $$default is not defined - Workflow execution fails in Local World on Turbo monorepo #367 (
$$default is not definederror) - Fix Applied: PR Fix default export workflow function transformation in workflow mode #373 tarball (
workflow@4.0.1-beta.17-3243a7b) - Result: Original error likely fixed, but blocked by this new Local World bug
Root Cause Analysis
Traced to @workflow/core/dist/runtime/world.js:
// Line 5: Creates require relative to index.js
const require = createRequire(join(process.cwd(), 'index.js'));
// Line 20: Determines target world
const targetWorld = process.env.WORKFLOW_TARGET_WORLD || defaultWorld();
// Line 37: If not 'embedded' or 'vercel', tries to require() as module
const mod = require(targetWorld);Problem: During Turbopack bundling/runtime, targetWorld appears to resolve to the string 'local' instead of 'embedded', causing require('local') to fail.
Environment
- Next.js: 16.0.0 (Turbopack - default bundler)
- Project: Turbo monorepo
- Runtime: Local World (development)
- OS: WSL2 Ubuntu
- Node: v22.x
- Package Manager: pnpm
Configuration
// next.config.mjs
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { withWorkflow } = require('workflow/next');
export default withWorkflow(nextConfig);No WORKFLOW_TARGET_WORLD environment variable is set (should default to 'embedded').
Reproduction Steps
- Create a Next.js 16 app with Turbopack in a Turbo monorepo
- Install workflow package:
pnpm add https://workflow-docs-git-fix-gh-367.vercel.sh/workflow.tgz - Create a workflow with default export
- Create an API route that imports
{ start } from 'workflow/api' - Start dev server:
pnpm dev - Make a POST request to trigger the workflow
- Observe
Cannot find module 'local'error
Observations
- ✅ Server starts successfully
- ✅ Workflow directives are discovered
- ✅ Steps bundle created
- ❌ Error occurs only when invoking a workflow via API route
- ✅
@workflow/world-localpackage IS installed correctly
Expected Behavior
targetWorld should resolve to 'embedded' and use createEmbeddedWorld() for Local World development.
Actual Behavior
targetWorld resolves to 'local', causing require('local') which fails because no such module exists.
Questions
- Is this a known Turbopack-specific issue?
- Is there a workaround for Local World module resolution?
- Should we test in Vercel World instead to validate the PR Fix default export workflow function transformation in workflow mode #373 fix?
Related
- Issue ReferenceError: $$default is not defined - Workflow execution fails in Local World on Turbo monorepo #367 (closed) - Original
$$default is not definederror - PR Fix default export workflow function transformation in workflow mode #373 - Fix for default export transformation
Thanks! 🙏
Metadata
Metadata
Assignees
Labels
No labels