惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
罗磊的独立博客
美团技术团队
B
Blog
量子位
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
博客园 - 聂微东
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
Blog — PlanetScale
Blog — PlanetScale
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题

Workflow SDK Documentation

Patterns for Defining Tools Human-in-the-Loop Building Durable AI Agents Queueing User Messages Resumable Streams Sleep, Suspense, and Scheduling Streaming Updates from Tools API Reference Workflow Globals Changelog Resilient run start Cookbook Building a World Deploying Astro Express Fastify Hono Getting Started NestJS Next.js Nitro Nuxt Python SvelteKit Vite corrupted-event-log fetch-in-workflow hook-conflict Errors
node-js-module-in-workflow
2026-05-31 · via Workflow SDK Documentation

Move Node.js core module usage to step functions instead of workflows.

This error occurs when you try to import or use Node.js core modules (like fs, http, crypto, path, etc.) directly inside a workflow function.

Cannot use Node.js module "fs" in workflow functions. Move this module to a step function.

Workflow functions run in a sandboxed environment without full Node.js runtime access. This restriction is important for maintaining determinism - the ability to replay workflows exactly and resume from where they left off after suspensions or failures.

Node.js modules have side effects and non-deterministic behavior that could break workflow replay guarantees.

Move any code using Node.js modules to a step function. Step functions have full Node.js runtime access.

For example, when trying to read a file in a workflow function, you should move the code to a step function.

Before:

import * as fs from "fs";

export async function processFileWorkflow(filePath: string) {
  "use workflow";

  // This will cause an error - Node.js module in workflow context
  const content = fs.readFileSync(filePath, "utf-8"); 
  return content;
}

After:

import * as fs from "fs";

export async function processFileWorkflow(filePath: string) {
  "use workflow";

  // Call step function that has Node.js access
  const content = await read(filePath); 
  return content;
}

async function read(filePath: string) {
  "use step";

  // Node.js modules are allowed in step functions
  return fs.readFileSync(filePath, "utf-8"); 
}

These common Node.js core modules cannot be used in workflow functions:

  • File system: fs, path
  • Network: http, https, net, dns
  • Process: child_process, cluster
  • Crypto: crypto (use Web Crypto API instead)
  • Operating system: os
  • Streams: stream (use Web Streams API instead)

You can use Web Platform APIs in workflow functions (like Headers, crypto.randomUUID(), Response, etc.), since these are available in the sandboxed environment. See Workflow Globals for the full list.