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

Linux/Darwin don't crash on spawn EBADF errors #913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

reinismu
Copy link

@reinismu reinismu commented Jun 11, 2024

When running on MacOS I notices that sometimes the call process spawn will crash

Error: spawn EBADF
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at spawn (node:child_process:761:9)
    at Object.execFile (node:child_process:351:17)
    at exec (node:child_process:234:25)
    at /Users/xpresshd/projects/poker/node/ddr/node_modules/systeminformation/lib/filesystem.js:604:9
    at processTicksAndRejections (node:internal/process/task_queues:77:11) {
  errno: -9,
  code: 'EBADF',
  syscall: 'spawn'
}

I would like to handle it and not crash my nodejs process

@sebhildebrandt
Copy link
Owner

@reinismu ... I have two questions

  • which node version you tried? I cannot reproduce it with any version
  • do you run systeminformation in any special context (nodemon, election, ...)??

@reinismu
Copy link
Author

@sebhildebrandt I use node v20.11.1 and run my code with just node.

I have a long running process that calls blockDevices every second. This happens usually after 4-5 hours of running.
maybe hitting ulimit. Invstigating now.

In any case I would like to handle that error

@sebhildebrandt
Copy link
Owner

@reinismu I agree, handling the error makes sense ... but then I would have to do it everywhere where we have exec ... and the handling needs to be a little bit different.

@sebhildebrandt
Copy link
Owner

@reinismu ... one more thing: running blockDevicesevery second is quite often ... this action takes at least 1-2 seconds, so I would extend the period ... and depending of the use case you have this could be even really long (or is it, that you want to detect changes like adding USB sticks, external SSDs...?)

I know. this might not solve the issue ... but still I would increase the poll interval.

@reinismu
Copy link
Author

@sebhildebrandt Thanks for suggestions! Will do that. Working with a legacy system and don't want to rewrite it yet.
1-2 seconds execution time might explain how it run out of file descriptors.

Ye, all exec's would need this then. This mostly just solved issue for me. Opened a PR so if someone else gets a similar issue they would have some info on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants