Emacs freezes for several seconds upon saving an Elm buffer after attempting to save with invalid syntax
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.
- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.
- [X] The issue can be reproduced on the **latest** available commit of Doom.
- [X] The issue can be reproduced on a stable release of Emacs, such as 27 or 28. *(Doom does not support development builds like 29+ or any version ending in .50 or .9x)*
### Expected behavior
When I save an Elm buffer, it is formatted and save immediately (within reason).
### Current behavior
When I save an Elm buffer, sometimes Emacs freezes entirely for several seconds before finally formatting the buffer and saving.

Output from profiler-report:
```
554 66% - command-execute
544 65% - funcall-interactively
537 64% - helm-M-x
537 64% - helm-M-x-read-extended-command
535 64% - helm
535 64% - helm
535 64% - helm-internal
512 61% - helm-read-from-minibuffer
455 54% - timer-event-handler
455 54% - apply
450 54% - #
450 54% - helm-check-minibuffer-input
450 54% - helm-check-new-input
450 54% - helm-update
444 53% - helm--collect-matches
444 53% - helm-compute-matches
378 45% - helm-get-cached-candidates
378 45% - helm-get-candidates
378 45% - helm-interpret-value
378 45% - helm-apply-functions-from-source
378 45% - helm-candidates-in-buffer
378 45% - helm-candidates-in-buffer-1
378 45% - helm-search-from-candidate-buffer
378 45% - helm--search-from-candidate-buffer-1
378 45% - #
21 2% helm-fuzzy-search
2 0% - helm-mm-search
2 0% - helm-mm-3-search
2 0% helm-mm-3-search-base
1 0% helm-candidates-in-buffer-search-default-fn
65 7% - helm-process-filtered-candidate-transformer
65 7% - helm-apply-functions-from-source
42 5% - helm-M-x-transformer-no-sort
36 4% - helm-M-x-transformer-1
19 2% - substitute-command-keys
9 1% - #
1 0% - kill-buffer
1 0% - replace-buffer-in-windows
1 0% unrecord-window-buffer
1 0% delete-char
18 2% - helm-fuzzy-highlight-matches
12 1% - helm-fuzzy-default-highlight-match
6 0% - #
1 0% - kill-buffer
1 0% #
5 0% - #
5 0% - helm-fuzzy-matching-default-sort-fn-1
3 0% - #
3 0% - helm-score-candidate-for-pattern
3 0% helm-fuzzy-flex-style-score
1 0% - helm--fuzzy-match-maybe-set-pattern
1 0% - helm--mapconcat-pattern
1 0% split-string-and-unquote
4 0% + helm-render-source
1 0% + helm--update-move-first-line
1 0% + #
3 0% treemacs--process-file-events
1 0% + #
1 0% #
10 1% + helm-update
3 0% + minibuffer-inactive-mode
1 0% smartparens-global-mode-check-buffers
18 2% + helm-initialize
1 0% + #
1 0% + helm-execute-selection-action
2 0% + helm-make-source
5 0% + save-buffer
1 0% + evil-delete
1 0% + evil-next-line
10 1% + byte-code
256 30% + ...
12 1% + redisplay_internal (C function)
5 0% + timer-event-handler
2 0% + #
```
### Steps to reproduce
1. Open Emacs
2. Open a correctly formatted Elm file
3. Make a change
4. Save
5. Observe the expected saving timing
6. Make a change that causes a syntax error (changing `module X exposing (myFunction)` to `module X exposing ()` seems to trigger the bug every time) and save the file
7. From now on, until Doom Emacs is restarted, any time you save an Elm file Emacs will freeze for several seconds before doing so, regardless of whether the syntax error is still present
### System Information
https://pastebin.com/EicdQ0d3
Contributor guide
Assessment
This issue has not been assessed yet.