You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug?]: (cross-post) EBADF: bad file descriptor, fstat with latest NodeJS v25 releases #7065
Don't know if this has anything to do with their esm loader's load hook returning source: undefined when passed format: 'commonjs'. Looking at the debug output, createCJSModuleWrap was previously being called with translateContext.source fully populated, whereas it's now being called with translateContext.source: undefined.
This seems to suggest there may be a way to fix this here. Otherwise if this is a break in NodeJS behavior which should be addressed there, it might be worthwhile to post additional context on nodejs/node#62012.
I'm experiencing this issue with commitlint. Originally, it failed when opening commitlint's main module, but that was resolved by yarn unplug commitlint. Now, it occurs when accessing semver. Specifically, file:///home/noah/.yarn/berry/cache/semver-npm-7.7.4-746e538da5-10c0.zip/node_modules/semver/index.js
$ yarn commitlint
node:fs:386
const stats = binding.fstat(fd, false, undefined, true /* shouldNotThrow */);
^
Error: EBADF: bad file descriptor, fstat
at tryStatSync (node:fs:386:25)
at readFileSync (node:fs:442:17)
at getSourceSync (node:internal/modules/esm/load:37:14)
at createCJSModuleWrap (node:internal/modules/esm/translators:211:32)
at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:350:10)
at #translate (node:internal/modules/esm/loader:451:20)
at afterLoad (node:internal/modules/esm/loader:507:29)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:512:12)
at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:555:36)
at afterResolve (node:internal/modules/esm/loader:603:52) {
errno: -9,
code: 'EBADF',
syscall: 'fstat'
}
Node.js v25.9.0
To learn which package(s) failed to load, I ran the CLI command in a javascript debugger and checked the path variable in the readFileSync part of the call stack.
For now, I've locked down Engines in my package.json files and set up NVM.
Is this still happening to anyone else with yarn 4.14.1 on node v24.15 and >=25.7?
I have to set my engines.node to >=18.0 <24.15 || >=25.0 <25.7 and use a strict node version check script in my .yarnrc.yml to guarantee compatibility without confusing errors.
The following error occurs when running mocha with yarn.
Mocha is its latest version, v11.7.5:
λ yarn -v
4.14.1
λ yarn mocha --exit --require ts-node/register/transpile-only --require source-map-support/register --recursive \"./test/*.spec.ts\" --timeout 30000
node:fs:391
const stats = binding.fstat(fd, false, undefined, true /* shouldNotThrow */);
^
Error: EBADF: bad file descriptor, fstat
at tryStatSync (node:fs:391:25)
at readFileSync (node:fs:447:17)
at getSourceSync (node:internal/modules/esm/load:37:14)
at createCJSModuleWrap (node:internal/modules/esm/translators:210:32)
at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:349:10)
at #translate (node:internal/modules/esm/loader:451:20)
at afterLoad (node:internal/modules/esm/loader:507:29)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:512:12)
at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:555:36)
at afterResolve (node:internal/modules/esm/loader:603:52) {
errno: -4083,
code: 'EBADF',
syscall: 'fstat'
}
Node.js v24.15.0
On windows 11 using nvm, I'm not sure if this is windows-latest
> nvm use 25.9
Now using node v25.9.0 (64-bit)
> yarn test:http
node:fs:386
const stats = binding.fstat(fd, false, undefined, true /* shouldNotThrow */);
^
Error: EBADF: bad file descriptor, fstat
at tryStatSync (node:fs:386:25)
at readFileSync (node:fs:442:17)
at getSourceSync (node:internal/modules/esm/load:37:14)
at createCJSModuleWrap (node:internal/modules/esm/translators:211:32)
at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:350:10)
at #translate (node:internal/modules/esm/loader:451:20)
at afterLoad (node:internal/modules/esm/loader:507:29)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:512:12)
at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:555:36)
at afterResolve (node:internal/modules/esm/loader:603:52) {
errno: -4083,
code: 'EBADF',
syscall: 'fstat'
}
Node.js v25.9.0
Node.js fixed the regression, we're waiting for the next 24.x and 25.x releases
For anyone else that was curious, I guess this was because yarn patches the 'fs' api to add support for .zip files before node uses it in its ESM loader, and a recent node update affected the loading order of modules so that the unpatched versions of fs functions would be cached before yarn and other modules would patch them.
It appears that a simple update was all that was needed for now, which loads the fs methods needed by the ESM loader upon their use instead of caching them upon module load (before yarn can patch them)
It seems that node may not leave FS patchable like this forever, but at the same time there is a virtual filesystem PR under review that looks promising. Hopefully we won't have to deal with these random fs issues for much longer, then.
Reacted by Jan Kowalleck, Matei Stanca and Mark Adamson
nodejs/node#62835 did not make it to 26.0.0 unfortunately, but is in 26.1.0 so hopefully from there on things are working. No idea when 24/25 are receiving new releases, but the fix should be in the respective branches already.
(and from what it seems test matrix above seems to confirm this claim)
Activity
Run Actions using Node.js LTS versions
Run Actions using Node.js LTS versions
ZeWaka commentedon Mar 17, 2026
Yep getting this too! Here are some debug logs if it helps assist.
Using yarn
4.12.0PnP, Nodev25.8.1, rspack1.7.8logspam
MODULE 8692: Module._load checking cache for assert false MODULE 8692: load built-in module assert ESM 8692: Storing file:///X:/repos/goonstation/tgui/[eval1] (implicit type) in ModuleLoadMap ESM 8692: Storing file:///X:/repos/goonstation/tgui/[eval1] (implicit type) in ModuleLoadMap ESM 8692: ModuleJob.run() ModuleWrap { hasTopLevelAwait: false, sourceURL: undefined, sourceMapURL: undefined, synthetic: false, url: 'file:///X:/repos/goonstation/tgui/[eval1]', isMain: true } ESM 8692: async addJobsToDependencyGraph() file:///X:/repos/goonstation/tgui/[eval1] ModuleJob { loader: ModuleLoader { loadCache: LoadCache(1) [Map] { 'file:///X:/repos/goonstation/tgui/[eval1]' => [Object: null prototype] }, isForAsyncLoaderHookWorker: false }, importAttributes: [Object: null prototype] {}, phase: 2, isMain: false, inspectBrk: false, url: 'file:///X:/repos/goonstation/tgui/[eval1]', module: ModuleWrap { hasTopLevelAwait: false, sourceURL: undefined, sourceMapURL: undefined, synthetic: false, url: 'file:///X:/repos/goonstation/tgui/[eval1]', isMain: true }, modulePromise: Promise { ModuleWrap { hasTopLevelAwait: false, sourceURL: undefined, sourceMapURL: undefined, synthetic: false, url: 'file:///X:/repos/goonstation/tgui/[eval1]', isMain: true } }, commonJsDeps: [], linked: [], instantiated: undefined } ESM 8692: Translating CJSModule file:///X:/repos/goonstation/tgui/.yarn/__virtual__/@rspack-core-virtual-f57d04e700/0/cache/@rspack-core-npm-1.4.11-6fbee5ea82-56a3a98f34.zip/node_modules/@rspack/core/dist/index.js [Object: null prototype] { format: 'commonjs', responseURL: 'file:///X:/repos/goonstation/tgui/.yarn/__virtual__/@rspack-core-virtual-f57d04e700/0/cache/@rspack-core-npm-1.4.11-6fbee5ea82-56a3a98f34.zip/node_modules/@rspack/core/dist/index.js', source: undefined, translatorKey: 'commonjs' } Error: EBADF: bad file descriptor, fstat at tryStatSync (node:fs:386:25) at readFileSync (node:fs:442:17) at getSourceSync (node:internal/modules/esm/load:37:14) at createCJSModuleWrap (node:internal/modules/esm/translators:209:32) at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:348:10) at #translate (node:internal/modules/esm/loader:451:20) at afterLoad (node:internal/modules/esm/loader:507:29) at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:512:12) at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:555:36) at afterResolve (node:internal/modules/esm/loader:603:52) { errno: -4083, code: 'EBADF', syscall: 'fstat' }fix: Node 25.7+ EBADF by reading CJS source of zip files (#7070)
BinToss commentedon Apr 6, 2026
I'm experiencing this issue with commitlint. Originally, it failed when opening commitlint's main module, but that was resolved by
yarn unplug commitlint. Now, it occurs when accessingsemver. Specifically,file:///home/noah/.yarn/berry/cache/semver-npm-7.7.4-746e538da5-10c0.zip/node_modules/semver/index.jsTo learn which package(s) failed to load, I ran the CLI command in a javascript debugger and checked the
pathvariable in thereadFileSyncpart of the call stack.For now, I've locked down Engines in my package.json files and set up NVM.
brandonbothell commentedon Apr 22, 2026
Is this still happening to anyone else with yarn 4.14.1 on node v24.15 and >=25.7?
I have to set my engines.node to
>=18.0 <24.15 || >=25.0 <25.7and use a strict node version check script in my.yarnrc.ymlto guarantee compatibility without confusing errors.The following error occurs when running
mochawithyarn.Mocha is its latest version,
v11.7.5:jkowalleck commentedon Apr 22, 2026
Tested: https://github.com/jkowalleck/playground_yarn4_EBADF_tests
Test matrix results: https://github.com/jkowalleck/playground_yarn4_EBADF_tests/actions/runs/24769755781
brandonbothell commentedon Apr 22, 2026
On windows 11 using nvm, I'm not sure if this is windows-latest
tfp-rv commentedon Apr 24, 2026
Can confirm, also still experiencing this on Windows with yarn 4.14.1 and node 25.9.0.
arcanis commentedon Apr 24, 2026
Node.js fixed the regression, we're waiting for the next 24.x and 25.x releases
brandonbothell commentedon Apr 24, 2026
For anyone else that was curious, I guess this was because yarn patches the 'fs' api to add support for .zip files before node uses it in its ESM loader, and a recent node update affected the loading order of modules so that the unpatched versions of
fsfunctions would be cached before yarn and other modules would patch them.It appears that a simple update was all that was needed for now, which loads the
fsmethods needed by the ESM loader upon their use instead of caching them upon module load (before yarn can patch them)It seems that node may not leave FS patchable like this forever, but at the same time there is a virtual filesystem PR under review that looks promising. Hopefully we won't have to deal with these random fs issues for much longer, then.
jkowalleck commentedon Apr 25, 2026
confirm and agree.
re #7065 (comment)
Tested: https://github.com/jkowalleck/playground_yarn4_EBADF_tests
Test matrix results: https://github.com/jkowalleck/playground_yarn4_EBADF_tests/actions/runs/24923966694
waiting for the next 24.x and 25.x releases
fix: docker dev build (Yarn 4.14.1) + soft-delete leak in paginated l…
jkowalleck commentedon May 6, 2026
addded node26 and node24-nightly to my tests:
Tested: https://github.com/jkowalleck/playground_yarn4_EBADF_tests
Test matrix results: https://github.com/jkowalleck/playground_yarn4_EBADF_tests/actions/runs/25425869432
used yarn v4.14.1
findings
jnoordsij commentedon May 6, 2026
nodejs/node#62835 did not make it to 26.0.0 unfortunately, but is in 26.1.0 so hopefully from there on things are working. No idea when 24/25 are receiving new releases, but the fix should be in the respective branches already.
(and from what it seems test matrix above seems to confirm this claim)
Don't use yarn in publish scripts
SparK-Cruz commentedon May 18, 2026
Failing on both ubuntu and manjaro, node 25.9
pin actions node version
fix(ci): Upgrade Yarn to 4.14.1 + install libusb for native modules
jnoordsij commentedon Jul 23, 2026
This should be fixed now on all supported Node.js versions. 25 is considered EOL and as such will never receive a fix for this anymore.
Correct the Node constraint: exclude the broken window, not cap at 24