Skip to content

Commit 70e7837

Browse files
committed
Add a Troubleshooting section to the README
1 parent 61cda72 commit 70e7837

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,98 @@ direct evals from a Clojure buffer behave like typing into the REPL.
511511
For the deeper rationale and a walkthrough of each module, see
512512
[`doc/design.md`](doc/design.md).
513513

514+
## Troubleshooting
515+
516+
A few first stops when something doesn't work the way you expect, in
517+
roughly the order you should reach for them.
518+
519+
### Watch the wire
520+
521+
`M-x port-toggle-message-log` (or `(setq port-log-messages t)`) mirrors
522+
every outgoing form and incoming parsed message to `*port-messages*`,
523+
timestamped to the millisecond and labelled `user` / `tool`. This is
524+
the single most useful Port-specific debugging tool: when something
525+
looks wrong, the log usually shows whether the request was even sent,
526+
whether a response came back, and what shape it had.
527+
528+
Two cautions:
529+
530+
- Leave the log off when you're not debugging. Every incoming message
531+
is `pp`'d into the buffer; on a big response (e.g. the completion
532+
warm-up's full ns-map) that pretty-printing can itself cost
533+
measurable time.
534+
- If Emacs hangs *while the log is on*, see if disabling it
535+
(`port-log-messages nil`) fixes things — `pp` formatting a large
536+
payload is sometimes the actual culprit.
537+
538+
### Capture a backtrace from a hang
539+
540+
If Emacs locks up, you can interrupt it with `C-g` and get a backtrace
541+
of exactly where it was stuck:
542+
543+
```
544+
M-x toggle-debug-on-quit RET ;; arm C-g for a backtrace
545+
;; reproduce the hang
546+
C-g ;; interrupts; *Backtrace* pops open
547+
```
548+
549+
The top few frames usually point straight at the offender. Attach
550+
the backtrace to a bug report.
551+
552+
### Profile a slow operation
553+
554+
For sluggishness that isn't a full hang:
555+
556+
```
557+
M-x profiler-start RET RET ;; CPU profiler
558+
;; reproduce the slow operation
559+
M-x profiler-report
560+
```
561+
562+
The report shows which functions consumed the most time. Look for
563+
Port-side hot spots (e.g. `port-client--parse-messages`,
564+
`port-completion--candidates`) versus consumer-side ones (corfu,
565+
company, eldoc).
566+
567+
### Isolate Port's caching layer
568+
569+
If you suspect the completion cache:
570+
571+
```elisp
572+
(setq port-completion-use-cache nil)
573+
```
574+
575+
This drops back to one synchronous query per keystroke (slower but
576+
with bounded response sizes). If the symptom disappears, the cache
577+
or the warm-up is involved; if it persists, look elsewhere.
578+
`M-x port-completion-clear-cache` forces a fresh fetch without
579+
disabling the cache entirely.
580+
581+
### Check the JVM side
582+
583+
In jack-in mode, the spawned JVM's stdout/stderr goes to
584+
`*port-server*` (a sibling buffer to the REPL). If a Port command
585+
silently does nothing, that buffer often has the answer (e.g. an
586+
unresolved class, a port already in use, a startup exception before
587+
the prepl server came up).
588+
589+
For runtime errors on either socket, `*port-stacktrace*` carries the
590+
parsed cause chain and a navigable trace (`RET` on a frame jumps to
591+
the source, even into jar contents).
592+
593+
### What to include in a bug report
594+
595+
When in doubt:
596+
597+
- Emacs version (`M-x emacs-version`).
598+
- Port version (`port-version`).
599+
- The contents of `*Messages*` since the symptom appeared.
600+
- A `*port-messages*` excerpt around the suspect interaction.
601+
- The `*Backtrace*` from a `C-g` during the hang, if applicable.
602+
- Whatever's relevant from `*port-server*` (in jack-in mode).
603+
604+
Issues go to [the Port issue tracker](https://github.com/clojure-emacs/port/issues).
605+
514606
## Limitations (today)
515607

516608
- No inline overlays or debugger. (The tool socket makes both tractable;

0 commit comments

Comments
 (0)