isaacs / node-graceful-fs

fs with incremental backoff on EMFILE
ISC License
1.27k stars 148 forks source link

TypeError: Cannot define property Symbol(graceful-fs.queue), object is not extensible #245

Open niieani opened 8 months ago

niieani commented 8 months ago

When used in an ESM context, node:fs module is not extensible. graceful-fs tries to define a Symbol property on the fs namespace here:

https://github.com/isaacs/node-graceful-fs/blob/234379906b7d2f4c9cfeb412d2516f42b0fb4953/graceful-fs.js#L24-L30

This causes a TypeError:

Object.defineProperty(context, gracefulQueue, {
         ^

TypeError: Cannot define property Symbol(graceful-fs.queue), object is not extensible

Would be best if the check were to be implemented differently, rather than defining a property on node's fs module.

xmedeko commented 6 months ago

Maybe use WeakMap (and drop support for very old version of Node)?