[BUG] Error: ENOENT: no such file or directory, open '/var/task/node_modules/playwright-core/browsers.json' on Vercel with Next.js

See original GitHub issue

After upgrade Playwright to 1.9.2 this error is happening on Vercel functions.

2021-03-16T19:57:07.806Z	undefined	ERROR	Error: ENOENT: no such file or directory, open '/var/task/node_modules/playwright-core/browsers.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at new Registry (/var/task/node_modules/playwright-core/lib/utils/registry.js:213:54)
    at new Playwright (/var/task/node_modules/playwright-core/lib/server/playwright.js:46:23)
    at Object.createPlaywright (/var/task/node_modules/playwright-core/lib/server/playwright.js:59:12)
    at setupInProcess (/var/task/node_modules/playwright-core/lib/inprocess.js:24:37)
    at Object.<anonymous> (/var/task/node_modules/playwright-core/lib/inprocess.js:42:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/var/task/node_modules/playwright-core/browsers.json'
}
RequestId: fafc5e6c-b338-4ba2-90b0-a019fd78923b Error: Runtime exited with error: exit status 1
Runtime.ExitError

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
mxschmittcommented, Apr 21, 2021

The issue should be fixed in the npm install playwright-core@next version and lands in version 1.11. I tested it and it’s working for one of my projects.

cc @BrunoQuaresma @jeadev @j2is @tiivik @dbredvick @zephraph

4reactions
zephraphcommented, Mar 30, 2021

Hey folks, I don’t think this is a playwright issue. I also don’t think it’s cache issue. When Vercel prepares serverless functions, it traces what dependencies/files are used and only includes those in the payload. What’s likely happening here is that the tracing mechanism doesn’t “see” this browser.json file as a dependency and thus doesn’t upload it to the lambda. I wrote a little about the tracing process if you’re interested.

I fixed this in my PR above, but note that I’m not using a Next.js api function but rather a Vercel api function. That’s necessary because you’ll have to explicitly include the browsers.json file in vercel’s config in order to get it to work (and you can’t do that w/ next functions). Also, as mentioned in my linked blog post, Next server dependencies are all bundled together so by placing playwright (and therefore chromium) in your Next.js function you’re risking pushing yourself over the 50MB function limit.

This issue should probably be reported to Vercel.

This could be fixed in playwright by removing the dynamic loading of browser.json if there’s appetite for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sign up - GitHub
ENOENT : no such file or directory, stat '/vercel/path0/.vercel/ ... I verified that the issue exists in the latest Next.js canary release ...
Read more >
ENOENT: no such file or directory when deployed to Vercel
This was a static site, how was I getting a server error? This was happening on my homepage and while most of the...
Read more >
Deploy NextJS on Vercel - Website Production Error ENOENT ...
I ran into a similar issue trying to call fs methods. Try adding output: 'standalone' to your next.config.js
Read more >
How to Load Data from a File in Next.js – Vercel Docs
A possible solution is to: Store your json files in a private folder inside your application; Construct an API endpoint to load these...
Read more >
Next.js API routes: How to read files from directory ... - Medium
ERROR : ENOENT: No such file or directory, scandir '/vercel/workpath0/public/img'. So let's refactor our api route to be compatible with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found