Skip to content

Conversation

ThomasK33
Copy link
Member

Summary

Fixes #51 - Prevents "nvim_echo must not be called in a fast event context" errors that occur when TCP connection errors are triggered from timer callbacks (e.g., after laptop sleep/wake).

  • Wrap vim.notify calls for ERROR and WARN levels in vim.schedule()
  • Add comprehensive test suite for logger fast event context safety
  • All logging levels now safely callable from any event context

Changes

  • Modified lua/claudecode/logger.lua to wrap ERROR and WARN vim.notify calls in vim.schedule()
  • Added tests/unit/logger_spec.lua with comprehensive test coverage for fast event context safety
  • Ensures all logging functions can be called safely from timer callbacks and other fast event contexts

The fix specifically addresses the error stack trace from the issue where logger.error() was called from server/tcp.lua:254 within a timer callback, which is a fast event context where direct vim API calls are not allowed.

…t context errors

Fixes issue where closing and reopening MacBook would trigger TCP connection
errors that call logger.error() from timer callbacks (fast event context),
causing "nvim_echo must not be called in a fast event context" errors.

Changes:
- Wrap vim.notify calls for ERROR and WARN levels in vim.schedule()
- Add comprehensive test suite for logger fast event context safety
- All logging levels now safely callable from any event context

Fixes #51

Change-Id: I9791d9e788745225aeac7c19c6c33562f95f086b
Signed-off-by: Thomas Kosiewski <[email protected]>
Fixes test failures caused by missing vim.schedule function in the
local vim mock used by selection_test.lua. The logger now requires
vim.schedule to be available for all logging levels.

Change-Id: Iec504a23187522a4f7968ec88d85476719a177d4
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 merged commit 2603ec0 into main Jun 20, 2025
3 checks passed
@ThomasK33 ThomasK33 deleted the fix/fast-event-context-logging branch June 20, 2025 08:50
tzssangglass added a commit to tzssangglass/codecompanion-history.nvim that referenced this pull request Jul 9, 2025
ravitemer pushed a commit to ravitemer/codecompanion-history.nvim that referenced this pull request Jul 9, 2025
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.

[BUG] nvim_echo must not be called in a fast event context
1 participant