fix(cli/process/logs): Reset log sequence on process restart to avoid false log gap warnings
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-08-30 - 5.4.2 - fix(cli/process/logs)
|
||||
Reset log sequence on process restart to avoid false log gap warnings
|
||||
|
||||
- Track process runId when streaming logs and initialize lastRunId from fetched logs
|
||||
- When a new runId is detected, reset lastSeq so that subsequent streamed logs are accepted (prevents spurious gap warnings)
|
||||
- Emit an informational message when a restart/runId change is detected to aid debugging of log streams
|
||||
|
||||
## 2025-08-30 - 5.4.1 - fix(processmonitor)
|
||||
Bump tsbuild devDependency and relax ps-tree callback typing in ProcessMonitor
|
||||
|
||||
|
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tspm',
|
||||
version: '5.4.1',
|
||||
version: '5.4.2',
|
||||
description: 'a no fuzz process manager'
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ export function registerLogsCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
console.log('─'.repeat(60));
|
||||
|
||||
let lastSeq = 0;
|
||||
let lastRunId: string | undefined = undefined;
|
||||
for (const log of response.logs) {
|
||||
const timestamp = new Date(log.timestamp).toLocaleTimeString();
|
||||
const prefix =
|
||||
@@ -60,11 +61,18 @@ export function registerLogsCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
: '[SYS]';
|
||||
console.log(`${timestamp} ${prefix} ${log.message}`);
|
||||
if (log.seq !== undefined) lastSeq = Math.max(lastSeq, log.seq);
|
||||
if ((log as any).runId) lastRunId = (log as any).runId;
|
||||
}
|
||||
|
||||
await withStreamingLifecycle(
|
||||
async () => {
|
||||
await tspmIpcClient.subscribe(id, (log: any) => {
|
||||
// Reset sequence if runId changed (e.g., process restarted)
|
||||
if (log.runId && log.runId !== lastRunId) {
|
||||
console.log(`[INFO] Detected process restart (runId changed).`);
|
||||
lastSeq = -1;
|
||||
lastRunId = log.runId;
|
||||
}
|
||||
if (log.seq !== undefined && log.seq <= lastSeq) return;
|
||||
if (log.seq !== undefined && log.seq > lastSeq + 1) {
|
||||
console.log(
|
||||
|
Reference in New Issue
Block a user