fix: packet log millisecond timestamps and date column#2403
Conversation
Packets within the same second appeared in wrong order because the ORDER BY used timestamp DESC, created_at DESC — both in seconds. Adding id DESC as tiebreaker guarantees insertion order (request before response) when timestamps match. Addresses #2364 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review AnalysisTodo List:
Review SummaryThis is a well-implemented fix for a subtle ordering issue in the packet monitor. The change replaces ✅ Strengths1. Correct Problem Identification
2. Optimal Solution
3. Code Quality
|
Timestamps were stored as Unix seconds, causing traceroute request/response packets arriving within the same second to have undefined sort order. Now stores Date.now() (milliseconds) for proper ordering. - Backend: Date.now() instead of Math.floor(Date.now() / 1000) - Frontend: auto-detect seconds vs ms for backward compat with old data - API: since parameter auto-detects seconds vs milliseconds Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review AnalysisTodo List:
Review SummaryThis is a well-implemented and thoughtful fix for a subtle but important ordering issue in the packet monitor. The PR addresses both the root cause and provides defensive measures. ✅ Strengths1. Correct Problem Diagnosis
2. Comprehensive Solution Approach
3. Code Quality & Implementation Database Layer ( ORDER BY pl.timestamp DESC, pl.id DESC LIMIT ${limit} OFFSET ${offset}
Backend Changes (
Frontend Compatibility (
API Compatibility ( function normalizeSinceToMs(value: string): number {
const n = parseInt(value, 10);
return n < 10_000_000_000 ? n * 1000 : n;
}
🔍 Technical AnalysisPerformance Impact: ✅ Positive
Security: ✅ No Concerns
Database Compatibility: ✅ Excellent
|
- Add "Date" column showing "Today" or short date for older packets - Fix 12h time format to show "12:09:55.979 PM" instead of "12:09:55 PM.979" - Extract toMs() helper for backward-compatible timestamp conversion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review AnalysisTodo List:
Review SummaryThis is a comprehensive and well-engineered fix for packet ordering issues in the packet monitor. The implementation addresses both the root cause and provides robust backward compatibility. ✅ Strengths1. Comprehensive Problem Resolution
2. Excellent Backward Compatibility Strategy
3. Code Quality Excellence // Efficient primary key sorting with tiebreaker
ORDER BY pl.timestamp DESC, pl.id DESC LIMIT ${limit} OFFSET ${offset}
🔍 Technical AnalysisDatabase Layer (
Backend Changes (
Frontend Compatibility (
API Layer (
🚀 Performance & Security AssessmentPerformance: ✅ Improved
Security: ✅ No Concerns
🎯 Architecture AlignmentThis change perfectly aligns with MeshMonitor's architectural principles:
📋 Minor Observations1. Localization Enhancement (
2. Code Consistency:
3. Edge Case Handling:
Final AssessmentCode Quality: ⭐⭐⭐⭐⭐ Outstanding
Problem Solving: ⭐⭐⭐⭐⭐ Exemplary
Technical Merit: ⭐⭐⭐⭐⭐ Excellent
Recommendation✅ Approved for merge - This is a high-quality fix that demonstrates excellent software engineering practices. The implementation is technically sound, thoroughly tested, and provides significant user experience improvement for packet monitoring during high-activity periods. The solution elegantly handles the challenging requirement of maintaining backward compatibility while fixing a subtle but important ordering bug. The defensive programming approach (dual fixes + compatibility layer) ensures robust operation across different deployment scenarios. |
Summary
Fixes packet monitor showing traceroute request/response in wrong order when both arrive within the same second, and improves timestamp display.
timestampcolumn stored Unix seconds (Math.floor(Date.now() / 1000)), so same-second packets had identical timestamps and undefined sort orderid DESCas tiebreaker sort key (defense-in-depth)Date.now()(milliseconds) for proper sub-second ordering12:09:55.979 PMinstead of12:09:55 PM.979sinceparameter accepts either formatCloses #2364
Changes
src/server/meshtasticManager.tsDate.now()instead ofMath.floor(Date.now() / 1000)at both write pointssrc/components/PacketMonitorPanel.tsxtoMs()helper, fixed 12h ms formattingsrc/server/routes/packetRoutes.tsnormalizeSinceToMs()forsincequery paramsrc/server/routes/v1/packets.tsnormalizeSinceToMs()helpersrc/db/repositories/misc.tsid DESCtiebreaker (commit 1)public/locales/en.jsonpacket_monitor.column.dateandpacket_monitor.todaykeysTest plan
npx vitest run— 3070 tests passnpm run build— no TypeScript errorsHH:MM:SS.mmm AM/PM🤖 Generated with Claude Code