fix: add try/catch on machineId()
#7538
Closed
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 PR addresses an issue with the
@sanity/cli
package, which does not function correctly withturbo
version 2.0 or higher on Windows systems. The root of the issue lies in the use of thenode-machine-id
dependency for telemetry purposes. When run on Windows withturbo
, an error is thrown:This error persists even when telemetry is disabled, as the
machineId
function is still invoked. The PR resolves the issue by wrapping themachineId
call in a try/catch block to handle the error gracefully.Before:
After:
What to review
Review the changes in how
machineId
is handled within the telemetry update. Specifically, focus on the newgetDeviceId
function and ensure that it appropriately handles errors without disrupting telemetry or causing other side effects.@sanity/cli
turbo
v2.0+.Testing
Manual testing was performed on a Windows system using
turbo
version 2.0. The error previously thrown by thenode-machine-id
library was resolved by the newgetDeviceId
function. As this is a Windows-specific issue, the testing was focused on this environment.No automated tests were added due to the nature of the issue being specific to the Windows OS. However, manual tests confirmed that telemetry still functions as expected with and without valid machine IDs.
Notes for release
This change fixes compatibility between the @sanity/cli package and turbo v2.0+ on Windows systems.
turbo
v2.0+ on Windows.node-machine-id
dependency.