jscheid / prettier.el

Prettier code formatting for Emacs.
GNU General Public License v3.0
172 stars 12 forks source link

Emacs hangs frequently on M1 ios BigSur w/nodejs 15x #87

Closed hlolli closed 3 years ago

hlolli commented 3 years ago

Describe the bug This may be one of the worst bug reports I've made. Since there's no way to reproduce this.

But very randomly, my Emacs hangs, I can't type for like a minute or two, so I repeat C-g constantly until this appears

Waiting for process to die...(type C-g again to kill it instantly)
Quit
prettier-process (local) quit unexpectedly: hangup: 1

Knowing that there's not much to do. An async handler or a force restart feature would make sense. This happens both on javascript with js-mode or in typescript with tide.

Link to M-x prettier-info output

;; Please create a Gist with the contents of this buffer.

;; MAKE SURE TO REMOVE ANY SENSITIVE INFORMATION FIRST

(:emacs-version "GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))\n of 2020-08-12" :prettier-el-version "1.1.0" :buffer-file-name "/Users/hlodversigurdsson/csound/csound/wasm/browser/externs.js" :remote-id nil :major-mode js-mode :exec-path
                ("/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_14" "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_14" "/Applications/Emacs.app/Contents/MacOS/libexec" "/Applications/Emacs.app/Contents/MacOS/bin" "/Users/hlodversigurdsson/.local/share/nvm/v15.12.0/bin" "/Users/hlodversigurdsson/.nix-profile/bin" "/Users/hlodversigurdsson/.nix-profile/bin" "/usr/local/opt/crowdin@2/bin" "/opt/homebrew/bin" "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_14" "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_14")
                :env
                ("TERM=dumb" "LANG=en_DE.UTF-8" "XPC_FLAGS=0x0" "XPC_SERVICE_NAME=application.org.gnu.Emacs.1841528.1841566" "TMPDIR=/var/folders/dl/wsff34ws06z_qttpc9wn9zh80000gn/T/" "__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2" "HOME=/Users/hlodversigurdsson" "SHELL=/bin/zsh" ...private data removed... "COMMAND_MODE=unix2003" "__CFBundleIdentifier=org.gnu.Emacs" ...private....)
                :prettier-options
                (:versions
                 (:node "15.12.0" :v8 "8.6.395.17-node.27" :uv "1.41.0" :zlib "1.2.11" :brotli "1.0.9" :ares "1.17.1" :modules "88" :nghttp2 "1.42.0" :napi "8" :llhttp "2.1.3" :openssl "1.1.1j+quic" :cldr "38.1" :icu "68.2" :tz "2020d" :unicode "13.0" :prettier "2.2.1")
                 :options
                 (:useTabs nil :tabWidth 2 :endOfLine "lf" :printWidth 100 :singleQuote nil :trailingComma "all" :jsxBracketSameLine nil :plugins
                           [(:languages
                             [(:linguistLanguageId 183 :name "JavaScript" :type "programming" :tmScope "source.js" :aceMode "javascript" :codemirrorMode "javascript" :codemirrorMimeType "text/javascript" :color "#f1e05a" :aliases
                                                   ["js" "node"]
                                                   :extensions
                                                   [".js" "._js" ".bones" ".cjs" ".es" ".es6" ".frag" ".gs" ".jake" ".jsb" ".jscad" ".jsfl" ".jsm" ".jss" ".mjs" ".njs" ".pac" ".sjs" ".ssjs" ".xsjs" ".xsjslib" ".wxs"]
                                                   :filenames
                                                   ["Jakefile"]
                                                   :interpreters
                                                   ["chakra" "d8" "gjs" "js" "node" "nodejs" "qjs" "rhino" "v8" "v8-shell"]
                                                   :since "0.0.0" :parsers
                                                   ["babel" "espree" "meriyah" "babel-flow" "babel-ts" "flow" "typescript"]
                                                   :vscodeLanguageIds
                                                   ["javascript" "mongo"])
                              (:linguistLanguageId 183 :name "Flow" :type "programming" :tmScope "source.js" :aceMode "javascript" :codemirrorMode "javascript" :codemirrorMimeType "text/javascript" :color "#f1e05a" :aliases
                                                   []
                                                   :extensions
                                                   [".js.flow"]
                                                   :filenames
                                                   []
                                                   :interpreters
                                                   ["chakra" "d8" "gjs" "js" "node" "nodejs" "qjs" "rhino" "v8" "v8-shell"]
                                                   :since "0.0.0" :parsers
                                                   ["flow" "babel-flow"]
                                                   :vscodeLanguageIds
                                                   ["javascript"])
                              (:linguistLanguageId 178 :name "JSX" :type "programming" :group "JavaScript" :extensions
                                                   [".jsx"]
                                                   :tmScope "source.js.jsx" :aceMode "javascript" :codemirrorMode "jsx" :codemirrorMimeType "text/jsx" :since "0.0.0" :parsers
                                                   ["babel" "babel-flow" "babel-ts" "flow" "typescript" "espree" "meriyah"]
                                                   :vscodeLanguageIds
                                                   ["javascriptreact"])
                              (:linguistLanguageId 378 :name "TypeScript" :type "programming" :color "#2b7489" :aliases
                                                   ["ts"]
                                                   :interpreters
                                                   ["deno" "ts-node"]
                                                   :extensions
                                                   [".ts"]
                                                   :tmScope "source.ts" :aceMode "typescript" :codemirrorMode "javascript" :codemirrorMimeType "application/typescript" :since "1.4.0" :parsers
                                                   ["typescript" "babel-ts"]
                                                   :vscodeLanguageIds
                                                   ["typescript"])
                              (:linguistLanguageId 94901924 :name "TSX" :type "programming" :group "TypeScript" :extensions
                                                   [".tsx"]
                                                   :tmScope "source.tsx" :aceMode "javascript" :codemirrorMode "jsx" :codemirrorMimeType "text/jsx" :since "1.4.0" :parsers
                                                   ["typescript" "babel-ts"]
                                                   :vscodeLanguageIds
                                                   ["typescriptreact"])
                              (:linguistLanguageId 174 :name "JSON.stringify" :type "data" :tmScope "source.json" :aceMode "json" :codemirrorMode "javascript" :codemirrorMimeType "application/json" :searchable nil :extensions
                                                   []
                                                   :filenames
                                                   ["package.json" "package-lock.json" "composer.json"]
                                                   :since "1.13.0" :parsers
                                                   ["json-stringify"]
                                                   :vscodeLanguageIds
                                                   ["json"])
                              (:linguistLanguageId 174 :name "JSON" :type "data" :tmScope "source.json" :aceMode "json" :codemirrorMode "javascript" :codemirrorMimeType "application/json" :searchable nil :extensions
                                                   [".json" ".avsc" ".geojson" ".gltf" ".har" ".ice" ".JSON-tmLanguage" ".mcmeta" ".tfstate" ".tfstate.backup" ".topojson" ".webapp" ".webmanifest" ".yy" ".yyp"]
                                                   :filenames
                                                   [".arcconfig" ".htmlhintrc" ".tern-config" ".tern-project" ".watchmanconfig" "composer.lock" "mcmod.info" ".prettierrc"]
                                                   :since "1.5.0" :parsers
                                                   ["json"]
                                                   :vscodeLanguageIds
                                                   ["json"])
                              (:linguistLanguageId 423 :name "JSON with Comments" :type "data" :group "JSON" :tmScope "source.js" :aceMode "javascript" :codemirrorMode "javascript" :codemirrorMimeType "text/javascript" :aliases
                                                   ["jsonc"]
                                                   :extensions
                                                   [".jsonc" ".sublime-build" ".sublime-commands" ".sublime-completions" ".sublime-keymap" ".sublime-macro" ".sublime-menu" ".sublime-mousemap" ".sublime-project" ".sublime-settings" ".sublime-theme" ".sublime-workspace" ".sublime_metrics" ".sublime_session"]
                                                   :filenames
                                                   [".babelrc" ".eslintrc.json" ".jscsrc" ".jshintrc" ".jslintrc" "devcontainer.json" "jsconfig.json" "language-configuration.json" "tsconfig.json" "tslint.json" ".eslintrc"]
                                                   :since "1.5.0" :parsers
                                                   ["json"]
                                                   :vscodeLanguageIds
                                                   ["jsonc"])
                              (:linguistLanguageId 175 :name "JSON5" :type "data" :extensions
                                                   [".json5"]
                                                   :tmScope "source.js" :aceMode "javascript" :codemirrorMode "javascript" :codemirrorMimeType "application/json" :since "1.13.0" :parsers
                                                   ["json5"]
                                                   :vscodeLanguageIds
                                                   ["json5"])]
                             :options
                             (:arrowParens
                              (:since "1.9.0" :category "JavaScript" :type "choice" :default
                                      [(:since "1.9.0" :value "avoid")
                                       (:since "2.0.0" :value "always")]
                                      :description "Include parentheses around a sole arrow function parameter." :choices
                                      [(:value "always" :description "Always include parens. Example: `(x) => x`")
                                       (:value "avoid" :description "Omit parens when possible. Example: `x => x`")])
                              :bracketSpacing
                              (:since "0.0.0" :category "Common" :type "boolean" :default t :description "Print spaces between brackets." :oppositeDescription "Do not print spaces between brackets.")
                              :jsxBracketSameLine
                              (:since "0.17.0" :category "JavaScript" :type "boolean" :default nil :description "Put > on the last line instead of at a new line.")
                              :semi
                              (:since "1.0.0" :category "JavaScript" :type "boolean" :default t :description "Print semicolons." :oppositeDescription "Do not print semicolons, except at the beginning of lines which may need them.")
                              :singleQuote
                              (:since "0.0.0" :category "Common" :type "boolean" :default nil :description "Use single quotes instead of double quotes.")
                              :jsxSingleQuote
                              (:since "1.15.0" :category "JavaScript" :type "boolean" :default nil :description "Use single quotes in JSX.")
                              :quoteProps
                              (:since "1.17.0" :category "JavaScript" :type "choice" :default "as-needed" :description "Change when properties in objects are quoted." :choices
                                      [(:value "as-needed" :description "Only add quotes around object properties where required.")
                                       (:value "consistent" :description "If at least one property in an object requires quotes, quote all properties.")
                                       (:value "preserve" :description "Respect the input use of quotes in object properties.")])
                              :trailingComma
                              (:since "0.0.0" :category "JavaScript" :type "choice" :default
                                      [(:since "0.0.0" :value nil)
                                       (:since "0.19.0" :value "none")
                                       (:since "2.0.0" :value "es5")]
                                      :description "Print trailing commas wherever possible when multi-line." :choices
                                      [(:value "es5" :description "Trailing commas where valid in ES5 (objects, arrays, etc.)")
                                       (:value "none" :description "No trailing commas.")
                                       (:value "all" :description "Trailing commas wherever possible (including function arguments).")]))
                             :printers
                             (:estree
                              (:handleComments nil)
                              :estree-json nil)
                             :parsers
                             (:babel
                              (:astFormat "estree")
                              :babel-flow
                              (:astFormat "estree")
                              :babel-ts
                              (:astFormat "estree")
                              :json
                              (:astFormat "estree")
                              :json5
                              (:astFormat "estree")
                              :json-stringify
                              (:astFormat "estree-json")
                              :__js_expression
                              (:astFormat "estree")
                              :__vue_expression
                              (:astFormat "estree")
                              :__vue_event_binding
                              (:astFormat "estree")
                              :flow
                              (:astFormat "estree")
                              :typescript
                              (:astFormat "estree")
                              :__ng_action
                              (:astFormat "estree")
                              :__ng_binding
                              (:astFormat "estree")
                              :__ng_interpolation
                              (:astFormat "estree")
                              :__ng_directive
                              (:astFormat "estree")
                              :espree
                              (:astFormat "estree")
                              :meriyah
                              (:astFormat "estree")))
                            (:languages
                             [(:linguistLanguageId 50 :name "CSS" :type "markup" :tmScope "source.css" :aceMode "css" :codemirrorMode "css" :codemirrorMimeType "text/css" :color "#563d7c" :extensions
                                                   [".css" ".wxss"]
                                                   :since "1.4.0" :parsers
                                                   ["css"]
                                                   :vscodeLanguageIds
                                                   ["css"])
                              (:linguistLanguageId 262764437 :name "PostCSS" :type "markup" :tmScope "source.postcss" :group "CSS" :extensions
                                                   [".pcss" ".postcss"]
                                                   :aceMode "text" :since "1.4.0" :parsers
                                                   ["css"]
                                                   :vscodeLanguageIds
                                                   ["postcss"])
                              (:linguistLanguageId 198 :name "Less" :type "markup" :color "#1d365d" :extensions
                                                   [".less"]
                                                   :tmScope "source.css.less" :aceMode "less" :codemirrorMode "css" :codemirrorMimeType "text/css" :since "1.4.0" :parsers
                                                   ["less"]
                                                   :vscodeLanguageIds
                                                   ["less"])
                              (:linguistLanguageId 329 :name "SCSS" :type "markup" :color "#c6538c" :tmScope "source.css.scss" :aceMode "scss" :codemirrorMode "css" :codemirrorMimeType "text/x-scss" :extensions
                                                   [".scss"]
                                                   :since "1.4.0" :parsers
                                                   ["scss"]
                                                   :vscodeLanguageIds
                                                   ["scss"])]
                             :options
                             (:singleQuote
                              (:since "0.0.0" :category "Common" :type "boolean" :default nil :description "Use single quotes instead of double quotes."))
                             :printers
                             (:postcss nil)
                             :parsers
                             (:css
                              (:astFormat "postcss")
                              :less
                              (:astFormat "postcss")
                              :scss
                              (:astFormat "postcss")))
                            (:languages
                             [(:linguistLanguageId 155 :name "Handlebars" :type "markup" :color "#f7931e" :aliases
                                                   ["hbs" "htmlbars"]
                                                   :extensions
                                                   [".handlebars" ".hbs"]
                                                   :tmScope "text.html.handlebars" :aceMode "handlebars" :since nil :parsers
                                                   ["glimmer"]
                                                   :vscodeLanguageIds
                                                   ["handlebars"])]
                             :printers
                             (:glimmer nil)
                             :parsers
                             (:glimmer
                              (:astFormat "glimmer")))
                            (:languages
                             [(:linguistLanguageId 139 :name "GraphQL" :type "data" :color "#e10098" :extensions
                                                   [".graphql" ".gql" ".graphqls"]
                                                   :tmScope "source.graphql" :aceMode "text" :since "1.5.0" :parsers
                                                   ["graphql"]
                                                   :vscodeLanguageIds
                                                   ["graphql"])]
                             :options
                             (:bracketSpacing
                              (:since "0.0.0" :category "Common" :type "boolean" :default t :description "Print spaces between brackets." :oppositeDescription "Do not print spaces between brackets."))
                             :printers
                             (:graphql nil)
                             :parsers
                             (:graphql
                              (:astFormat "graphql")))
                            (:languages
                             [(:linguistLanguageId 222 :name "Markdown" :type "prose" :color "#083fa1" :aliases
                                                   ["pandoc"]
                                                   :aceMode "markdown" :codemirrorMode "gfm" :codemirrorMimeType "text/x-gfm" :wrap t :extensions
                                                   [".md" ".markdown" ".mdown" ".mdwn" ".mkd" ".mkdn" ".mkdown" ".ronn" ".workbook"]
                                                   :filenames
                                                   ["contents.lr" "README"]
                                                   :tmScope "source.gfm" :since "1.8.0" :parsers
                                                   ["markdown"]
                                                   :vscodeLanguageIds
                                                   ["markdown"])
                              (:linguistLanguageId 222 :name "MDX" :type "prose" :color "#083fa1" :aliases
                                                   ["pandoc"]
                                                   :aceMode "markdown" :codemirrorMode "gfm" :codemirrorMimeType "text/x-gfm" :wrap t :extensions
                                                   [".mdx"]
                                                   :filenames
                                                   []
                                                   :tmScope "source.gfm" :since "1.15.0" :parsers
                                                   ["mdx"]
                                                   :vscodeLanguageIds
                                                   ["mdx"])]
                             :options
                             (:proseWrap
                              (:since "1.8.2" :category "Common" :type "choice" :default
                                      [(:since "1.8.2" :value t)
                                       (:since "1.9.0" :value "preserve")]
                                      :description "How to wrap prose." :choices
                                      [(:since "1.9.0" :value "always" :description "Wrap prose if it exceeds the print width.")
                                       (:since "1.9.0" :value "never" :description "Do not wrap prose.")
                                       (:since "1.9.0" :value "preserve" :description "Wrap prose as-is.")])
                              :singleQuote
                              (:since "0.0.0" :category "Common" :type "boolean" :default nil :description "Use single quotes instead of double quotes."))
                             :printers
                             (:mdast nil)
                             :parsers
                             (:remark
                              (:astFormat "mdast")
                              :markdown
                              (:astFormat "mdast")
                              :mdx
                              (:astFormat "mdast")))
                            (:languages
                             [(:linguistLanguageId 146 :name "Angular" :type "markup" :tmScope "text.html.basic" :aceMode "html" :codemirrorMode "htmlmixed" :codemirrorMimeType "text/html" :color "#e34c26" :aliases
                                                   ["xhtml"]
                                                   :extensions
                                                   [".component.html"]
                                                   :since "1.15.0" :parsers
                                                   ["angular"]
                                                   :vscodeLanguageIds
                                                   ["html"]
                                                   :filenames
                                                   [])
                              (:linguistLanguageId 146 :name "HTML" :type "markup" :tmScope "text.html.basic" :aceMode "html" :codemirrorMode "htmlmixed" :codemirrorMimeType "text/html" :color "#e34c26" :aliases
                                                   ["xhtml"]
                                                   :extensions
                                                   [".html" ".htm" ".html.hl" ".inc" ".st" ".xht" ".xhtml" ".mjml"]
                                                   :since "1.15.0" :parsers
                                                   ["html"]
                                                   :vscodeLanguageIds
                                                   ["html"])
                              (:linguistLanguageId 146 :name "Lightning Web Components" :type "markup" :tmScope "text.html.basic" :aceMode "html" :codemirrorMode "htmlmixed" :codemirrorMimeType "text/html" :color "#e34c26" :aliases
                                                   ["xhtml"]
                                                   :extensions
                                                   []
                                                   :since "1.17.0" :parsers
                                                   ["lwc"]
                                                   :vscodeLanguageIds
                                                   ["html"]
                                                   :filenames
                                                   [])
                              (:linguistLanguageId 391 :name "Vue" :type "markup" :color "#2c3e50" :extensions
                                                   [".vue"]
                                                   :tmScope "text.html.vue" :aceMode "html" :since "1.10.0" :parsers
                                                   ["vue"]
                                                   :vscodeLanguageIds
                                                   ["vue"])]
                             :printers
                             (:html nil)
                             :options
                             (:htmlWhitespaceSensitivity
                              (:since "1.15.0" :category "HTML" :type "choice" :default "css" :description "How to handle whitespaces in HTML." :choices
                                      [(:value "css" :description "Respect the default value of CSS display property.")
                                       (:value "strict" :description "Whitespaces are considered sensitive.")
                                       (:value "ignore" :description "Whitespaces are considered insensitive.")])
                              :vueIndentScriptAndStyle
                              (:since "1.19.0" :category "HTML" :type "boolean" :default nil :description "Indent script and style tags in Vue files."))
                             :parsers
                             (:html
                              (:astFormat "html")
                              :vue
                              (:astFormat "html")
                              :angular
                              (:astFormat "html")
                              :lwc
                              (:astFormat "html")))
                            (:languages
                             [(:linguistLanguageId 407 :name "YAML" :type "data" :color "#cb171e" :tmScope "source.yaml" :aliases
                                                   ["yml"]
                                                   :extensions
                                                   [".yml" ".mir" ".reek" ".rviz" ".sublime-syntax" ".syntax" ".yaml" ".yaml-tmlanguage" ".yaml.sed" ".yml.mysql"]
                                                   :filenames
                                                   [".clang-format" ".clang-tidy" ".gemrc" "glide.lock"]
                                                   :aceMode "yaml" :codemirrorMode "yaml" :codemirrorMimeType "text/x-yaml" :since "1.14.0" :parsers
                                                   ["yaml"]
                                                   :vscodeLanguageIds
                                                   ["yaml" "ansible" "home-assistant"])]
                             :printers
                             (:yaml nil)
                             :options
                             (:bracketSpacing
                              (:since "0.0.0" :category "Common" :type "boolean" :default t :description "Print spaces between brackets." :oppositeDescription "Do not print spaces between brackets.")
                              :singleQuote
                              (:since "0.0.0" :category "Common" :type "boolean" :default nil :description "Use single quotes instead of double quotes.")
                              :proseWrap
                              (:since "1.8.2" :category "Common" :type "choice" :default
                                      [(:since "1.8.2" :value t)
                                       (:since "1.9.0" :value "preserve")]
                                      :description "How to wrap prose." :choices
                                      [(:since "1.9.0" :value "always" :description "Wrap prose if it exceeds the print width.")
                                       (:since "1.9.0" :value "never" :description "Do not wrap prose.")
                                       (:since "1.9.0" :value "preserve" :description "Wrap prose as-is.")]))
                             :parsers
                             (:yaml
                              (:astFormat "yaml")))]
                           :arrowParens "always" :bracketSpacing t :cursorOffset -1 :embeddedLanguageFormatting "auto" :htmlWhitespaceSensitivity "css" :insertPragma nil :jsxSingleQuote nil :pluginSearchDirs
                           []
                           :proseWrap "preserve" :quoteProps "as-needed" :rangeEnd 1 :rangeStart 0 :requirePragma nil :semi t :vueIndentScriptAndStyle nil :astFormat "estree" :printer
                           (:handleComments nil))))

To Reproduce :(

Expected behavior Hangups can happen, but perhaps this can be less noticeable.

Additional context Tide also tends to hangup and exit, so this could be related to the nodejs process. Otoh, while at work, I have nodejs running all day, sometimes few days.

jscheid commented 3 years ago

Ah! I've noticed something similar recently. I didn't notice any prettier-process (local) quit unexpectedly: hangup messages and put it down to running an 28.x snapshot, and it's happening so rarely for me that so far I didn't feel the need to investigate more. But now, reading your bug report, it does sound like there might be something wrong with this package. It would be something in a recent version because it only started a month or two ago for me. I have a hunch it might be related to the new timeout handling in #78.

Could you install this version and see if that works better? I think you can do so with straight.el or qelpa and I'll also attach a tarball here soon.

jscheid commented 3 years ago

You can use this link to download a Tarball: https://github.com/jscheid/prettier.el/suites/2172435994/artifacts/44656850

(You will have to unzip it to get the tar file).

hlolli commented 3 years ago

Thanks for fast reply! I will test this one, tar file is good. I'm working today, so I should have results from this experiment tonight or tomorrow latest! I may even try some modifications to see if I can make sense of the problem. I don't want to guess, but I'm making some guesses in my mind to what could cause this. More later!

hlolli commented 3 years ago

@jscheid following up, I've been using that tarball under heavy conditions. It stalled in total twice. Which is way way less than before (every hour on average before). It seemed to me that both of these stalls happened when I had multiple projects open with prettier mode and I was running prettier on multiple locations. Not sure if at the same time or around the same time. But I'm happy with how this is now and I definitely don't feel distracted.

jscheid commented 3 years ago

Thanks for reporting back. Glad to hear it's working better now, I might revert that change then. But really it shouldn't stall, ever. The next time it does, after pressing C-g, could you check the *prettier (local)* buffer to see if there's anything in there and send it over if so?

hlolli commented 3 years ago

yes, will do!

hlolli commented 3 years ago

I missed an opportunity I guess. I'm not getting this buffer, it's not appearing on my buffer list. I only got

Saving file [hidden].js...
Wrote [hidden].js
Waiting for process to die...(type C-g again to kill it instantly)
Quit
prettier-process (local) quit unexpectedly: hangup: 1

I guess there must be some debug variable I need to set?

jscheid commented 3 years ago

Ah, yes, sorry -- you need to set prettier-keep-server-buffer-flag to non-nil.

hlolli commented 3 years ago

2 weeks later, it's happening somewhat times a day. But the buffer *prettier (local)* stays empty, before or after crashing.

jscheid commented 3 years ago

@hlolli sorry for not having been very responsive, it's been a busy few weeks. I would still like to get to the bottom of it.

Re-reading your initial bug report, something caught my eye:

But very randomly, my Emacs hangs, I can't type for like a minute or two, so I repeat C-g constantly until this appears

I just wanted to check... does this happen when you save, or at other times? This package shouldn't be doing anything [1] when you're not saving, so that would be important to know.

[1] It does always wait on input from the sub-process in the background but that process would be idle outside of saving, and so there shouldn't be any reason for our handler to ever wake up.

hlolli commented 3 years ago

It happens at any time, I had to do a factory reset on my macbook because of faulty update, and same on master as in the zip version you posted above. It can happen at any time, while Im doing anything unrelevant. It's even hanging while no js or web-tech buffer is open (currently editing nix and clojure files, and prettier is freezing now and then).

jscheid commented 3 years ago

I'm starting to wonder whether prettier.el is a victim here rather than the perpetrator. It would be great if you could try a few things:

Also, a few more questions about your setup:

I wonder if this could be related to Big Sur Gatekeeper (OCSP). One way to find out would be to disable it using sudo spctl --master-disable, but I can't really ask you to do that as it would disable a central element of MacOS security.

hlolli commented 3 years ago

When I wrote the ticket, I used homebrew emacs, after my osx needed factory reset from faulty update, I've been on nix.

I'm starting to suspect either x86_64 vs ARM native node is somewhere miscommunicating. Or more likely the open filehandler limit is too low ($ ulimit -n ;; 256). This I started noticing in a react project after I did some upgrades, that many apps started crashing after the project started which led me to believe it's related what's happening here.

I'll try to upgrade to 28, there are more than 1 emacs mirror for nix packages which I could use. As well as upping the filehandler limit / configuring watchman better.

Feel free to close this, I see the code is super nice, google closure, top of the line minifier, so I can't see how prettier.el should be leaving a large trail. But somehow, the operating system kills it first before going on bigger apps (ex. Karabiner-Elements and Google-Chrome both tend to crash).

I'll maybe update on what configuration works best if I find good filehandler limit.

jscheid commented 3 years ago

Interesting. It didn't occur to me that some resource limit might be causing the Node process to crash, but of course that is absolutely a possibility. Here are a few other things you could try:

Good luck!