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

Reset initial counter state back to 0 #367

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

Conversation

AlexanderBelokon
Copy link

#322 fixed some issues with tape, but introduced a new one: the node process exits with a non-zero code in some scenarios. I believe this change is responsible for that, and reverting it fixes the issue for me.

tschaub#322 fixed some issues with `tape`, but introduced a new one: the node process exits with a non-zero code.
I believe [this change](https://github.com/tschaub/mock-fs/pull/322/files#diff-f003d52cb508b6a198d1aac361680301de0b3c0a9f800b3d3230da2923029322R271) is responsible for that, and reverting it fixes the issue for me.
@3cp
Copy link
Collaborator

3cp commented Sep 22, 2022

@tschaub do you recall why you set the counter to -1 when fixing the tape issue?

@tschaub
Copy link
Owner

tschaub commented Sep 23, 2022

Initializing the counter to -1 means that stdin will have a file descriptor of 0, stdout will get 1, and stderr will get 2 given the order that things are constructed. This lets people do things like fs.write(1, buffer) to write to stdout, which is what I understood that Tape does.

I should have added tests or comments to make this clearer.

I think we’ll need to get some more details on what doesn’t work in Tape before settling on a better fix.

@AlexanderBelokon
Copy link
Author

@tschaub Thank you for looking into this! I've created a repro for my problem when using tape and mock-fs on Node16+.

If you run npm run test in the repo, tape's output looks fine, but the exit code of the node process is 134 instead of 0, as if it was terminated abnormally.

If you run npm run hack it finishes with 0, as it should.

I wish I could provide an explanation for why that is, but as of now I can't. I really need this to work, though 😅

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