refactor: check if node via process.versions#222
Merged
ewanharris merged 1 commit intomainfrom Apr 23, 2025
Merged
Conversation
This removes the `process.title` check for node and uses `process.versions` instead, `process.title` is not really reliable as it can be set by code, for example some CLIs will rename the process, by using `process.versions.node` we can be more sure that we're in node, unless we're in a runtime that stubs this. Looking at the libuv codebase we can see that the `uv_get_process_title`[1] function has an assertion that the title retrieved is not empty, given that we've only seen this on Windows it's possible there's some permissions issue or similar that is causing this. [1] https://github.com/libuv/libuv/blob/47a5c85c4e7c63adc838d8e252fb4859e6cb743d/src/win/util.c#L390-L424 Closes #219
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #222 +/- ##
==========================================
+ Coverage 88.01% 88.18% +0.16%
==========================================
Files 23 23
Lines 1202 1202
Branches 211 192 -19
==========================================
+ Hits 1058 1060 +2
+ Misses 85 84 -1
+ Partials 59 58 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ewanharris
commented
Apr 23, 2025
Member
|
Nice investigation! |
rhamzeh
approved these changes
Apr 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This removes the
process.titlecheck for node and usesprocess.versionsinstead,process.titleis not really reliable as it can be set by code, for example some CLIs will rename the process, by using
process.versions.nodewe can be more sure that we're in node, unless we're in a runtime that stubs this.Looking at the libuv codebase we can see that the
uv_get_process_titlefunction has an assertion that the title retrieved is not empty, given that we've only seen this on Windows it's possible there's some permissions issue or similar that is causing this.References
Closes #219
Review Checklist
main