Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

fs.promises provided by Pkg does not implement the same API as defined in Node.js #1162

@janka102

Description

@janka102

Node.js has had fs.promises since v10. The definition seems to remain the same between versions all the way up to v16. It says that there is a FileHandle class and that fsPromises.open() returns an instance of that class. However, in pkg's bootstrap.js the fs.promises.open function is just a promisified version of the normal fs.open, which uses file descriptor numbers instead of the FileHandler class.

This makes it difficult to write code that uses fs.promises and have it run with node directly and with pkg. Also, fs.promises is essentially unusable with typescript now since it can't tell there is a different API. I searched the readme and other issues but have not found this called out anywhere.

It would be nice if this was at least called out in the readme. It took me some time to finally track down why my code wasn't working when pkged and having it called out in the readme might save others the trouble. Ideally though, I imagine it would be good to have a more compatible API for fs.promises.

I can start working on implementing a compatible API if there are no objections from any of the maintainers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions