{"record":{"id":"848e83854f02aacd","repo":"ComposioHQ/composio","slug":"file-system-operations-are-not-supported-in-this-r-848e83","errorCode":null,"errorMessage":"File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). Use environment variables or external storage services instead.","messagePattern":"File system operations are not supported in this runtime environment \\(Cloudflare Workers/Edge\\)\\. Use environment variables or external storage services instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/platform/workerd.ts","lineNumber":95,"sourceCode":"  },\n\n  realpathSync(filePath: string): string {\n    // No filesystem in edge runtimes: cannot resolve symlinks, so return the\n    // input unchanged. Local-path uploads don't happen on workerd anyway.\n    return filePath;\n  },\n\n  isFileSystemCaseSensitive(_filePath: string): boolean {\n    // Preserve exact matching when there is no filesystem to inspect.\n    return true;\n  },\n\n  mkdirSync(_dirPath: string): void {\n    // No-op in edge runtimes - directories cannot be created\n  },\n\n  readFileSync(_filePath: string, _encoding?: Uint8ArrayEncoding): never {\n    throw new Error(\n      'File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). ' +\n        'Use environment variables or external storage services instead.'\n    );\n  },\n\n  writeFileSync(\n    _filePath: string,\n    _content: string | Uint8Array,\n    _encoding?: Uint8ArrayEncoding\n  ): never {\n    throw new Error(\n      'File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). ' +\n        'Use environment variables or external storage services instead.'\n    );\n  },\n};\n","sourceCodeStart":77,"sourceCodeEnd":112,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/platform/workerd.ts#L77-L112","documentation":"In edge runtimes (Cloudflare Workers) the platform shim replaces Node's fs with stubs, and readFileSync always throws because no real filesystem exists in Workers. The library routes any file-read call through this shim, so code paths that read config/state from disk fail fast with a clear message instead of mysteriously failing.","triggerScenarios":"Deploying @composio/core (or code that calls its fs-using paths, e.g. file-based config/API-key loading) to Cloudflare Workers/edge, where the platform/workerd.ts shim is selected and readFileSync is invoked at runtime.","commonSituations":"Porting a Node service that reads a config file or .env-like file to Workers, local dev working (Node shim) while deployed Workers build throws, or a dependency assuming fs availability.","solutions":["Replace file reads with environment variables (wrangler vars/secrets) or external storage (KV, R2, D1)","Remove fs calls (including in dependencies) from code paths that run on Workers","Test with the Cloudflare runtime (pnpm test:e2e:cloudflare) before deploying"],"exampleFix":"// before\nconst config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));\n// after (Cloudflare Workers)\nconst config = JSON.parse(env.COMPOSIO_CONFIG_JSON);","handlingStrategy":"fallback","validationCode":"if (typeof (globalThis as any).WebSocketPair !== 'undefined' || navigator?.userAgent?.includes('Cloudflare-Workers')) {\n  // edge runtime: read from env instead of fs\n  config = JSON.parse(env.COMPOSIO_CONFIG_JSON);\n} else {\n  config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));\n}","typeGuard":"const isEdgeRuntime = (): boolean => typeof (globalThis as any).WebSocketPair !== 'undefined';","tryCatchPattern":"try { data = readFileSync(path, 'utf8'); } catch (e) { if (/not supported in this runtime/.test((e as Error).message)) { data = env[envKey]; } else throw e; }","preventionTips":["Avoid fs in any code that may run on edge runtimes","Use Workers secrets/vars or KV for configuration","Run the Cloudflare e2e suite before deploying"],"tags":["cloudflare-workers","edge-runtime","filesystem","unsupported-environment","typescript"],"backgroundTag":"filesystem-unsupported-in-edge-runtime","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}