Skip to content

Commit 13a58e4

Browse files
Report Sync errors in all pages. Fix bug where changes in sync errors were not detected.
1 parent 7659533 commit 13a58e4

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.changeset/fuzzy-ties-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/common': patch
3+
---
4+
5+
Fixed bug where changes in SyncStatus downloadError and uploadError might not be reported.

packages/common/src/db/crud/SyncStatus.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,22 @@ export class SyncStatus {
171171
* @returns {boolean} True if the instances are considered equal, false otherwise
172172
*/
173173
isEqual(status: SyncStatus) {
174-
return JSON.stringify(this.options) == JSON.stringify(status.options);
174+
/**
175+
* By default Error object are serialized to an empty object.
176+
* This replaces Errors with more useful information before serialization.
177+
*/
178+
const replacer = (_: string, value: any) => {
179+
if (value instanceof Error) {
180+
return {
181+
name: value.name,
182+
message: value.message,
183+
stack: value.stack
184+
};
185+
}
186+
return value;
187+
};
188+
189+
return JSON.stringify(this.options, replacer) == JSON.stringify(status.options, replacer);
175190
}
176191

177192
/**

tools/diagnostics-app/src/app/views/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import UserIcon from '@mui/icons-material/VerifiedUser';
1010
import WifiIcon from '@mui/icons-material/Wifi';
1111

1212
import {
13+
Alert,
1314
AppBar,
1415
Box,
1516
Divider,
@@ -192,6 +193,7 @@ export default function ViewsLayout({ children }: { children: React.ReactNode })
192193
</Drawer>
193194
</Box>
194195
<S.MainBox sx={{ flexGrow: 1, p: 3, width: { md: `calc(100% - ${drawerWidth}px)` }, marginTop: '50px' }}>
196+
{syncError ? <Alert severity="error">Sync error detected: {syncError.message}</Alert> : null}
195197
{children}
196198
</S.MainBox>
197199
</S.MainBox>

0 commit comments

Comments
 (0)