Skip to content

[Bug]: createRequire fails on Cloudflare Workers Runtime #2296

@rufiange

Description

@rufiange

SDK Language

TypeScript / Node.js SDK (@composio/core)

SDK Version

@composio/core@0.3.1

Runtime Environment

Cloudflare workers

Environment

Cloudflare Worker

Describe the Bug

@composio/core@0.3.1 fails in Cloudflare Workers with:

TypeError: The argument 'path' must be a file URL object, 
a file URL string, or an absolute path string. Received 'undefined'

Steps to Reproduce

import { Composio } from '@composio/core';

const composio = new Composio({ apiKey: 'xxx' });
// Fails in Cloudflare Workers

Error Output / Stack Trace

TypeError: The argument 'path' must be a file URL object, 
a file URL string, or an absolute path string. Received 'undefined'
    at createRequire (node:module)

Reproducibility

  • Always reproducible
  • Intermittent / Sometimes
  • Happened once, can’t reproduce

Additional Context or Screenshots

In Workers, import.meta.url is undefined.

Possible Workaround

Set platform: 'neutral' in ts/packages/core/tsdown.config.ts:

export default defineConfig({
  entry: ['src/index.ts'],
  format: ['esm', 'cjs'],
  dts: true,
  clean: true,
  minify: false,
  outDir: 'dist',
  tsconfig: './tsconfig.build.json',
+ platform: 'neutral',
  onSuccess() {
    console.info('🙏 Build succeeded!');
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions