Skip to content

feat: crash if sessions directory missing after init - #102

Merged
avoidwork merged 4 commits into
mainfrom
feat/crash-if-session-dir-missing
Jun 4, 2026
Merged

feat: crash if sessions directory missing after init#102
avoidwork merged 4 commits into
mainfrom
feat/crash-if-session-dir-missing

Conversation

@avoidwork

Copy link
Copy Markdown
Owner

Description

Move session directory creation from saveSession() to a one-time init function. If the sessions directory disappears after init, saveSession() throws and shutdown handlers treat it as fatal (crash with exit code 1).

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional choice)
  • Performance improvement
  • CI / build / tooling

Testing

All 955 tests pass including 5 new tests:

  • ensureSessionsDir creates directory when missing
  • ensureSessionsDir returns successfully when directory already exists
  • saveSession writes file successfully when directory exists
  • saveSession propagates writeFile errors unhandled
  • handleShutdown re-throws errors from saveSession

Coverage

  • 100% line coverage maintained for new files (ensureDir.js: 100% line, 100% branch, 100% function)
  • Overall coverage maintained at 96.30%

Checklist

  • npm run lint passes
  • Tests pass with 100% line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

Threat Model Considerations

  • Missing sessions directory after init is now a crash condition — this provides a signal that persistence is failing, which is preferred over silent data loss.
  • Write failures (disk full, permissions) also crash, providing the OS error message for diagnosis.
  • No changes to auth, secrets, or input validation surfaces.

avoidwork added 3 commits June 4, 2026 17:25
Move mkdir from saveSession() to ensureSessionsDir() init function.

- Create ensureSessionsDir() in src/session/index.js for one-time init
- Simplify saveSession() to pure writeFile with no mkdir/stat
- Shutdown handler propagates saveSession errors as fatal
- Add comprehensive tests for all new behavior
@avoidwork avoidwork self-assigned this Jun 4, 2026
@avoidwork
avoidwork merged commit 181f41a into main Jun 4, 2026
2 checks passed
@avoidwork
avoidwork deleted the feat/crash-if-session-dir-missing branch June 4, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant