Version
v26.0.0
Platform
Linux eric-cornelissen-Latitude-7640 6.17.0-29-generic #29~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon May 11 10:30:58 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
node:internal/navigator
What steps will reproduce the bug?
For the error mentioned in the title:
node -e 'globalThis.Navigator.prototype.hardwareConcurrency'
This applies to other getters of this object too, namely:
node -e 'globalThis.Navigator.prototype.locks'
node -e 'globalThis.Navigator.prototype.languages'
node -e 'globalThis.Navigator.prototype.userAgent'
node -e 'globalThis.Navigator.prototype.platform'
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Not an internal error about the implementation of the Navigator.
Based on the behavior of browsers1, a TypeError is still expected, but instead something like:
Uncaught TypeError: 'get hardwareConcurrency' called on an object that does not implement interface Navigator.
What do you see instead?
For hardwareConcurrency:
node:internal/navigator:100
this.#availableParallelism ??= getAvailableParallelism();
^
TypeError: Cannot read private member #availableParallelism from an object whose class did not declare it
at get hardwareConcurrency (node:internal/navigator:100:9)
at Reflect.get (<anonymous>)
at [eval]:1:9
at runScriptInThisContext (node:internal/vm:219:10)
at node:internal/process/execution:483:12
at [eval]-wrapper:6:24
at runScriptInContext (node:internal/process/execution:481:60)
at evalFunction (node:internal/process/execution:315:30)
at evalTypeScript (node:internal/process/execution:327:3)
at node:internal/main/eval_string:71:3
For the other properties a similar error about using a private member.
Additional information
-
I tested the hardwareConcurrency property on older versions too and found the report applies to v24.15.0 and v22.0.0 too, in v20.20.2 the Navigate global did not yet exist.
-
Interestingly the following property does not result in an error
node -e 'console.log(globalThis.Navigator.prototype.language)'
This might be a bug as well given that in browsers the only properties that can be accessed on this object are functions (whereas this is also a getter), which you can verify using:
for (const key of Object.keys(Navigator.prototype)) { try { Navigator.prototype[key]; console.log("no error for", key, typeof Navigator.prototype[key]) } catch { } }
Version
v26.0.0
Platform
Subsystem
node:internal/navigator
What steps will reproduce the bug?
For the error mentioned in the title:
This applies to other getters of this object too, namely:
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Not an internal error about the implementation of the
Navigator.Based on the behavior of browsers1, a
TypeErroris still expected, but instead something like:What do you see instead?
For
hardwareConcurrency:For the other properties a similar error about using a private member.
Additional information
I tested the
hardwareConcurrencyproperty on older versions too and found the report applies to v24.15.0 and v22.0.0 too, in v20.20.2 the Navigate global did not yet exist.Interestingly the following property does not result in an error
This might be a bug as well given that in browsers the only properties that can be accessed on this object are functions (whereas this is also a getter), which you can verify using:
Footnotes
I only tried Firefox. ↩