Skip to content
Snippets Groups Projects
Unverified Commit ff7be0d6 authored by Matiss Janis Aboltins's avatar Matiss Janis Aboltins Committed by GitHub
Browse files

:loud_sound: improving 'invalid-schema' error logs (#1302)

The logs for `invalid-schema` were not logging the used query or the
metadata. So fixing this.

It would make debugging issues such as
https://github.com/actualbudget/actual/issues/1296 easier.
parent 02b1e036
No related branches found
No related tags found
No related merge requests found
...@@ -81,17 +81,17 @@ function apply(msg: Message, prev?: boolean) { ...@@ -81,17 +81,17 @@ function apply(msg: Message, prev?: boolean) {
try { try {
if (prev) { if (prev) {
query = { query = {
sql: db.cache(`UPDATE ${dataset} SET ${column} = ? WHERE id = ?`), sql: `UPDATE ${dataset} SET ${column} = ? WHERE id = ?`,
params: [value, row], params: [value, row],
}; };
} else { } else {
query = { query = {
sql: db.cache(`INSERT INTO ${dataset} (id, ${column}) VALUES (?, ?)`), sql: `INSERT INTO ${dataset} (id, ${column}) VALUES (?, ?)`,
params: [row, value], params: [row, value],
}; };
} }
db.runQuery(query.sql, query.params); db.runQuery(db.cache(query.sql), query.params);
} catch (error) { } catch (error) {
throw new SyncError('invalid-schema', { throw new SyncError('invalid-schema', {
error: { message: error.message, stack: error.stack }, error: { message: error.message, stack: error.stack },
...@@ -564,11 +564,13 @@ export const fullSync = once(async function (): Promise< ...@@ -564,11 +564,13 @@ export const fullSync = once(async function (): Promise<
app.events.emit('sync', { app.events.emit('sync', {
type: 'error', type: 'error',
subtype: 'out-of-sync', subtype: 'out-of-sync',
meta: e.meta,
}); });
} else if (e.reason === 'invalid-schema') { } else if (e.reason === 'invalid-schema') {
app.events.emit('sync', { app.events.emit('sync', {
type: 'error', type: 'error',
subtype: 'invalid-schema', subtype: 'invalid-schema',
meta: e.meta,
}); });
} else if ( } else if (
e.reason === 'decrypt-failure' || e.reason === 'decrypt-failure' ||
...@@ -580,7 +582,7 @@ export const fullSync = once(async function (): Promise< ...@@ -580,7 +582,7 @@ export const fullSync = once(async function (): Promise<
meta: e.meta, meta: e.meta,
}); });
} else { } else {
app.events.emit('sync', { type: 'error' }); app.events.emit('sync', { type: 'error', meta: e.meta });
} }
} else if (e instanceof PostError) { } else if (e instanceof PostError) {
console.log(e); console.log(e);
......
---
category: Maintenance
authors: [MatissJanis]
---
Improved error logs for `invalid-schema` issues
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment