Skip to content

Fix: handle device creation errors and improve error handling in device fetching#276

Open
egalvis27 wants to merge 3 commits intomainfrom
fix/UI-error-when-create-device-fails
Open

Fix: handle device creation errors and improve error handling in device fetching#276
egalvis27 wants to merge 3 commits intomainfrom
fix/UI-error-when-create-device-fails

Conversation

@egalvis27
Copy link

What is Changed / Added


The user is experiencing an unusual issue with the preferences interface. The only relevant error in the logs relates to device creation, which is likely the root cause. It appears that an unresolved creation promise is propagating errors to the UI and causing the interface problems.

Solution implemented: Added catch blocks to prevent error propagation to the interface. This should resolve the issue by handling the promise rejection gracefully.

image

@egalvis27 egalvis27 requested a review from AlexisMora March 17, 2026 22:58
Comment on lines 48 to 49
.catch(() => {
setDeviceState({ status: 'ERROR' });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if getOrCreateDevice is already wrapped in tryCatch this is not necessary right

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const devices = await window.electron.devices.getDevices();
setDevices(devices);
try {
const devices = await window.electron.devices.getDevices();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could wrap the device/service.ts getDevices in a tryCatch instead so that every caller of this method is already safe

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const result = await fetchDevice({ deviceIdentifier: data });
return await handleFetchDeviceResult(result);
}
try {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could add a test for that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@egalvis27 egalvis27 requested a review from AlexisMora March 19, 2026 16:08
@sonarqubecloud
Copy link

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