Skip to content

sessionItem calls nowSeconds() twice in ternary, can produce negative remaining_secs #87

Description

@Sertug17

In src/commands/sessions.ts line 672-673, nowSeconds() is called twice within the same ternary expression without caching:

remaining_secs:
    record.grace_ready_at > nowSeconds() ? record.grace_ready_at - nowSeconds() : 0,

If the system clock ticks between the two calls (e.g., first returns 999, second returns 1001), the guard passes but the subtraction produces a negative value (-1).

The correct pattern is already used elsewhere in the same file closeOneSession (line 338) caches now:

const now = nowSeconds();

Suggested fix:

const now = nowSeconds();
// ...
remaining_secs: record.grace_ready_at > now ? record.grace_ready_at - now : 0,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions