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

Don't use process.exit in CLI to prevent truncated stdout #1905

Merged
merged 1 commit into from
May 24, 2021

Conversation

jakebailey
Copy link
Member

I'm working on the type completeness dashboard and hit nodejs/node#6379 (and associated issues) when capturing pyright's output.

Avoid using process.exit to stop the process, instead exiting gracefully with the exit code set. process.exit synchronously exits the process, but doesn't flush console's internal buffers or stdout. This can lead to a truncated output, especially when the output is large (which is the case with --verifytypes and many libraries). There isn't a good way to force a flush (besides calling undocumented functions to put stdout into blocking mode), so avoiding process.exit is a better method and fits with the NodeJS docs that say process.exit is not recommended.

After #1822 fixed the file watcher hang, this should be safe to do, but does rely on all promises resolving before the process can exit.

@jakebailey jakebailey requested a review from erictraut May 24, 2021 18:11
@erictraut
Copy link
Collaborator

Ah, good find. I didn't realize that process.exit exited without flushing. That explains some problems I've experienced in other node-based command-line tools I've written in the past :).

The changes LGTM.

@jakebailey jakebailey merged commit 173fd1b into microsoft:main May 24, 2021
@jakebailey jakebailey deleted the no-process-exit branch May 24, 2021 18:20
heejaechang added a commit to heejaechang/pyright that referenced this pull request Nov 3, 2021
Fixed relative import completion bugs and some refactorings.
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.

2 participants