Wrangler login throws an error on Linux

I am running ubuntu 22.04 and am trying to use wrangler login so that I can develop worker code.
Unfortunately the process breaks"

  1. The browser opens with the link to authorize the login.
  2. After clicking the Allow button in the browser, the script fails with the following error:
/home2/michel/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/wrangler/wrangler-dist/cli.js:29374
            throw a;
            ^

Error: EBADF: bad file descriptor, write
    at writeFileSync (node:fs:2352:20)
    at writeAuthConfigFile (/home2/michel/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/wrangler/wrangler-dist/cli.js:119085:37)
    at Server.<anonymous> (/home2/michel/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/wrangler/wrangler-dist/cli.js:119174:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -9,
  code: 'EBADF',
  syscall: 'write'
}

How can I login?

Are you using Node.js 21?

There appears to be some changes there with how writeFileSync (or something adjacent) works, which is causing some issues like this. Can you try using Node.js 20 LTS?

wrangler issue for reference: 🐛 BUG: EBADF: bad file descriptor, write · Issue #4540 · cloudflare/workers-sdk · GitHub

Hey,

Are you using Node.js 21? There seems to be a change done there impacting unix systems.
You can follow the Wrangler issue here: 🐛 BUG: EBADF: bad file descriptor, write · Issue #4540 · cloudflare/workers-sdk · GitHub

1 Like

Yes. I downgraded to v20.10 and it now works. Thanks.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.