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

Ensure fs operations are treated in a sequential way #3433

Open
oleiade opened this issue Oct 31, 2023 · 0 comments
Open

Ensure fs operations are treated in a sequential way #3433

oleiade opened this issue Oct 31, 2023 · 0 comments
Assignees

Comments

@oleiade
Copy link
Member

oleiade commented Oct 31, 2023

Feature Description

In the current state of the fs module, operations are not ensured to happen in an order-respecting-sequential manner.

As it appears other JS runtimes, such as Deno, do seem to ensure this ordering of operations (although we couldn't find official information about such guarantees), we would like to provide the same guarantee to users of the fs module.

Specifically, we would like to ensure the following behavior:

let s1 = file.operation(...)
let s2 = file.operation(...)  // the underlying operation will be executed after the `s1` underlying operation 
let s3 = file.operation(...)  // the underlying operation will be executed after the `s2` underlying operation
const result = await s3;  // we wait for the underlying operation execution to be done, and return its result

Suggested Solution (optional)

Two potential approaches have been proposed in this PR's discussion, namely:

  1. Define an internal representation of a filesystem command and use channels to ensure the execution ordering internally.
  2. Have the file struct keep a pointer to its latest operation, and when a new operation is issued, have it ensure that it awaits the resolution of the previous one implicitly before moving on and updating the pointer with itself.

Both of these solutions are untested and would need further exploration and research.

Already existing or connected issues / PRs (optional)

#3420
#3354

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

No branches or pull requests

1 participant