Skip to content

Workflow bundler fails to resolve Node.js built-ins, breaking database clients and HTTP libraries #140

@dnosk

Description

@dnosk

Description

The Workflow DevKit bundler fails to bundle workflow files that import packages using
Node.js built-in modules (e.g., stream, http, https, zlib, crypto). This
breaks most database clients, HTTP libraries, and cloud SDKs.

Environment

  • workflow: 4.0.1-beta.4
  • @workflow/next: 4.0.1-beta.4
  • Next.js: 16.0.0
  • Node.js: v23.x (or your version)
  • Platform: macOS/Linux/Windows

Error Output

  ✘ [ERROR] Could not resolve "stream"

  node_modules/@supabase/node-fetch/lib/index.js:8:37:
    8 │ var Stream = _interopDefault(require('stream'));
      ╵                                      ~~~~~~~~
    The package "stream" wasn't found on the file system but is built into node.
    Are you trying to bundle for node? You can use "platform: 'node'" to do that,
    which will remove this error.

  ✘ [ERROR] Could not resolve "http"
  ✘ [ERROR] Could not resolve "https"
  ✘ [ERROR] Could not resolve "zlib"
  ✘ [ERROR] Could not resolve "punycode"

  Error: Build failed with 7 errors

Reproduction Steps

  1. Install Workflow DevKit and Supabase client:
npm install workflow@4.0.1-beta.4 @supabase/supabase-js
  1. Create a workflow file using Supabase:
 // lib/workflows/example.ts
 import { createClient } from '@supabase/supabase-js'

 async function checkDatabase(userId: string) {
   "use step"

   const supabase = createClient(
     process.env.SUPABASE_URL!,
     process.env.SUPABASE_KEY!
   )

   const { data } = await supabase
     .from('users')
     .select('*')
     .eq('id', userId)
     .single()

   return data
 }

 export async function exampleWorkflow(args: { userId: string }) {
   "use workflow"

   const user = await checkDatabase(args.userId)
   return { user }
 }
  1. Run npm run dev
  2. Bundler fails with "Could not resolve" errors for Node.js built-ins

Root Cause

The workflow bundler appears to use platform: 'browser' configuration (or equivalent),
treating Node.js built-in modules as external dependencies that don't exist. However,
workflow steps actually execute in a Node.js environment on Vercel's servers.

Affected Packages

This issue breaks any package that uses Node.js built-ins:

Database Clients:

  • ❌ @supabase/supabase-js

HTTP Clients:

  • ❌ node-fetch

What Works:

  • ✅ Native fetch() (Web API)
  • ✅ Pure JavaScript libraries with no Node.js dependencies

Current Workaround

Replace client library calls with manual fetch() requests:

  // Instead of:
  const { data } = await supabase.from('table').select('*')

  // Use REST API directly:
  const res = await fetch(`${SUPABASE_URL}/rest/v1/table`, {
    headers: {
      'Authorization': `Bearer ${SUPABASE_KEY}`,
      'apikey': SUPABASE_KEY
    }
  })
  const data = await res.json()

This works but loses type safety, autocomplete, and requires manual query construction.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions