Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run inside Cloudflare workers due to __dirname usage in stagehand and playwright-core #164

Open
labithiotis opened this issue Nov 5, 2024 · 0 comments
Milestone

Comments

@labithiotis
Copy link

I would like to run this lib inside the cloudflare workers (if possible) and currently its failing due to usage of _dirname global var. Could where we use __dirname replace it with helper function that uses __dirname if defined otherwise import.meta.dirname or something.

✘ [ERROR] service core:user:extractor: Uncaught ReferenceError: __dirname is not defined

    at null.<anonymous> (worker.js:9810:156)
    at null.<anonymous> (worker.js:7360:58)
    at null.<anonymous> (worker.js:16846:17) in
  node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/utilsBundleImpl/index.js
    at null.<anonymous> (worker.js:32:50) in __require2
    at null.<anonymous> (worker.js:16901:37) in
  node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/utilsBundle.js
    at null.<anonymous> (worker.js:32:50) in __require2
    at null.<anonymous> (worker.js:28823:25) in
  node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/server/registry/index.js
    at null.<anonymous> (worker.js:32:50) in __require2
    at null.<anonymous> (worker.js:76867:21) in
  node_modules/.pnpm/[email protected]/node_modules/playwright-core/lib/server/index.js
    at null.<anonymous> (worker.js:32:50) in __require2

I suspect there may be other issues like access to FS that may prevent this from ever working.

I am also planning on using browserbase browser always so it would be nice if env was "BROWSERBASE" none of this code is included to avoid the issue. Maybe a better solution could be to have different bundled exports for LOCAL and BROWSERBASE instead of env flag so if we import StagehandExternal it doesn't include any browser code, and StagehandLocal does?

@kamath kamath added this to Stagehand Nov 29, 2024
@kamath kamath added this to the Foundation milestone Nov 29, 2024
@kamath kamath moved this to Todo in Stagehand Nov 29, 2024
@kamath kamath removed the status in Stagehand Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants