Skip to content

Commit 170cc2e

Browse files
authored
refactor: check if node via process.versions (#222)
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
1 parent 05c790e commit 170cc2e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class Configuration {
171171
const baseOptions = params.baseOptions || {};
172172
baseOptions.headers = baseOptions.headers || {};
173173

174-
if (typeof process === "object" && process.title === "node" && !baseOptions.headers["User-Agent"]) {
174+
if (typeof process === "object" && process.versions?.node && !baseOptions.headers["User-Agent"]) {
175175
baseOptions.headers["User-Agent"] = DEFAULT_USER_AGENT;
176176
}
177177

0 commit comments

Comments
 (0)