Enhance error handling in MQTT message processing to ignore MySQL error 1020 related to race conditions

This commit is contained in:
Anton Roslund 2026-01-05 15:57:17 +01:00
parent d9aaeb4479
commit db4008d86a

View file

@ -983,7 +983,12 @@ client.on("message", async (topic, message) => {
}, },
}); });
} catch (e) { } catch (e) {
console.error(e); // Ignore MySQL error 1020 "Record has changed since last read" - this is a race condition
// that occurs when multiple packets arrive concurrently for the same node
const errorMessage = e.message || String(e);
if (!errorMessage.includes('Record has changed since last read')) {
console.error(e);
}
} }
// Keep track of the names a node has been using. // Keep track of the names a node has been using.
@ -1006,7 +1011,12 @@ client.on("message", async (topic, message) => {
} }
}); });
} catch (e) { } catch (e) {
console.error(e); // Ignore MySQL error 1020 "Record has changed since last read" - this is a race condition
// that occurs when multiple packets arrive concurrently for the same node
const errorMessage = e.message || String(e);
if (!errorMessage.includes('Record has changed since last read')) {
console.error(e);
}
} }
} }