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

🐛 BUG: EBADF: bad file descriptor, write #4540

Closed
shirshak55 opened this issue Dec 2, 2023 · 4 comments
Closed

🐛 BUG: EBADF: bad file descriptor, write #4540

shirshak55 opened this issue Dec 2, 2023 · 4 comments
Labels
bug Something that isn't working

Comments

@shirshak55
Copy link

Which Cloudflare product(s) does this pertain to?

Workers Runtime, Wrangler core

What version(s) of the tool(s) are you using?

3.18

What version of Node are you using?

21.3.0

What operating system are you using?

Mac

Describe the Bug

Whenever I try to deploy cloudflare worker, I get this message

Attempting to login via OAuth...

And, it opens a link in browser. And, when I allow it in browser i get this error.

/Users/macbook/Desktop/projects/mike/tm_spinner_config/node_modules/wrangler/wrangler-dist/cli.js:29374
            throw a;
            ^

Error: EBADF: bad file descriptor, write
    at writeFileSync (node:fs:2352:20)
    at writeAuthConfigFile (/Users/macbook/Desktop/projects/mike/tm_spinner_config/node_modules/wrangler/wrangler-dist/cli.js:119084:37)
    at Server.<anonymous> (/Users/macbook/Desktop/projects/mike/tm_spinner_config/node_modules/wrangler/wrangler-dist/cli.js:119173:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -9,
  code: 'EBADF',
  syscall: 'write'
}

Node.js v21.3.



Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@shirshak55 shirshak55 added the bug Something that isn't working label Dec 2, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Dec 2, 2023
@mxschumacher
Copy link

mxschumacher commented Dec 2, 2023

Hello, I have the exact same issue. When downgrading the node version to 20.10.0 (latest LTS at the time of writing) and re-running the same commands, the login is successful for me.

Running

man 2 write | grep "EBADF"

We are told “EBADF fd is not a valid file descriptor or is not open for writing.”

I assume that within the node major version (from 20 to 21), something changes in fs.writeFileSync https://nodejs.org/api/fs.html#fswritefilesyncfile-data-options, I see that it is invoked in https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/user/user.ts#L869 from https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/user/user.ts#L978C28-L978C28

System context: I am using wrangler version 3.18.0 and node version 21.3.0 on Fedora Linux with kernel 6.5.12

As the developer docs for wrangler don’t specify an upper bounds for the node version to be installed, this is an easy trap to fall into. I think users should be encouraged to stay on the node LTS until further notice.

@Cherry
Copy link
Contributor

Cherry commented Dec 7, 2023

It looks like this was fixed in Node.js 21.4.0: nodejs/node#50990

@shirshak55
Copy link
Author

shirshak55 commented Dec 7, 2023

Update: It is working. It was my shell not using 21.4.0 instead of 21.3.0

Closing the issue. Thanks everyone for being involved.


I think if it is node issue, so this repo isn't responsible for this?

I have tried 21.4.0, and it doesn't seem to be fixed.

image

@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Dec 7, 2023
@mxschumacher
Copy link

Hello @shirshak55 , I don't think this issue should be closed. The docs define a lower bound of node version that is supported, but don't indicate an upper bound. Instead of letting users run into strange error messages due to problems with downstream dependencies, wrangler should give useful feedback and define the most recent node release that all tests have been passed on.

While this particular bug might have been resolved, the problem in general still stands. Node will keep changing and the package.json does not limit the upper bound of the version number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

3 participants