Skip to content

Commit 41234bb

Browse files
takaokoujiGemini
andcommitted
feat: add warning log for missing Mesh V2 server timestamps
- Added warning logs when using client time as a fallback for missing server timestamps in handleDataUpdate and fetchAllNodesData - Improves observability of potential server-side timestamp issues 🤖 Generated with [Gemini Code](https://gemini.google.com/code) Co-Authored-By: Gemini <noreply@google.com>
1 parent 080a72b commit 41234bb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/extensions/scratch3_mesh_v2/mesh-service.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ class MeshV2Service {
444444
}
445445

446446
// Use server timestamp with fallback to current time
447-
const serverTimestamp = nodeStatus.timestamp ? new Date(nodeStatus.timestamp).getTime() : Date.now();
447+
const serverTimestamp = nodeStatus.timestamp ?
448+
new Date(nodeStatus.timestamp).getTime() :
449+
(log.warn('Mesh V2: Missing server timestamp, using client time'), Date.now());
448450

449451
nodeStatus.data.forEach(item => {
450452
this.remoteData[nodeId][item.key] = {
@@ -929,7 +931,9 @@ class MeshV2Service {
929931
if (!this.remoteData[status.nodeId]) {
930932
this.remoteData[status.nodeId] = {};
931933
}
932-
const serverTimestamp = status.timestamp ? new Date(status.timestamp).getTime() : Date.now();
934+
const serverTimestamp = status.timestamp ?
935+
new Date(status.timestamp).getTime() :
936+
(log.warn('Mesh V2: Missing server timestamp, using client time'), Date.now());
933937
status.data.forEach(item => {
934938
this.remoteData[status.nodeId][item.key] = {
935939
value: item.value,

0 commit comments

Comments
 (0)