JSONHandler.Handle() called log.Println() to output JSON. Since Go 1.22+ bridges the standard log package through slog, and simplelog replaces the default slog handler in init(), this creates a recursive call that deadlocks on the log mutex.
Fix: replace log.Println with fmt.Fprintln(os.Stdout, ...) to write directly without going through the log/slog bridge.
Tested with the README example — runs cleanly now instead of deadlocking.
`JSONHandler.Handle()` called `log.Println()` to output JSON. Since Go 1.22+ bridges the standard `log` package through `slog`, and simplelog replaces the default slog handler in `init()`, this creates a recursive call that deadlocks on the log mutex.
Fix: replace `log.Println` with `fmt.Fprintln(os.Stdout, ...)` to write directly without going through the log/slog bridge.
Tested with the README example — runs cleanly now instead of deadlocking.
Closes #3
I wrote a regression test for this deadlock bug (see PR #7). The test reproduces the issue by calling slog.Info() with JSONHandler as the default handler and using a 5-second timeout to detect the deadlock.
Results:
❌ On main (without fix): test hangs/deadlocks as expected
✅ On fix/json-handler-deadlock (with fix): test passes immediately
=== RUN TestJSONHandlerDeadlock
--- PASS: TestJSONHandlerDeadlock (0.00s)
PASS
Confirmed: this PR correctly fixes the deadlock.
I wrote a regression test for this deadlock bug (see PR #7). The test reproduces the issue by calling `slog.Info()` with `JSONHandler` as the default handler and using a 5-second timeout to detect the deadlock.
**Results:**
- ❌ On `main` (without fix): test hangs/deadlocks as expected
- ✅ On `fix/json-handler-deadlock` (with fix): test passes immediately
```
=== RUN TestJSONHandlerDeadlock
--- PASS: TestJSONHandlerDeadlock (0.00s)
PASS
```
Confirmed: this PR correctly fixes the deadlock.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
JSONHandler.Handle()calledlog.Println()to output JSON. Since Go 1.22+ bridges the standardlogpackage throughslog, and simplelog replaces the default slog handler ininit(), this creates a recursive call that deadlocks on the log mutex.Fix: replace
log.Printlnwithfmt.Fprintln(os.Stdout, ...)to write directly without going through the log/slog bridge.Tested with the README example — runs cleanly now instead of deadlocking.
Closes #3
please write a failing test for this on another PR
@clawbot verify that the failing test is fixed by this patch
I wrote a regression test for this deadlock bug (see PR #7). The test reproduces the issue by calling
slog.Info()withJSONHandleras the default handler and using a 5-second timeout to detect the deadlock.Results:
main(without fix): test hangs/deadlocks as expectedfix/json-handler-deadlock(with fix): test passes immediatelyConfirmed: this PR correctly fixes the deadlock.
@clawbot remember to always make your PR source branches in the repo in question, not as a fork in your own user account.
clawbot referenced this pull request2026-09-03 15:06:34 +02:00