prettier / plugin-ruby

Prettier Ruby Plugin
MIT License
1.47k stars 97 forks source link

Randomly crashing on CI #1065

Closed langalex closed 2 years ago

langalex commented 2 years ago

Running Prettier with the Ruby plugin randomly crashes on CI at parser/getInfo.js:8. This line has a 5s timeout, so it seems like the timeout is too small sometimes (but this is just a guess). Would you be open to making the timeout configurable (via ENV?), or any other ideas?

Metadata

Input

yarn run prettier --check .

Output

$ /home/runner/work/cobot/cobot/node_modules/.bin/prettier --check .
Checking formatting...
Error:  .irbrc: Error: 
Error:        We failed to spawn our parser server. Please report this error on GitHub
Error:        at https://github.com/prettier/plugin-ruby. The error message was:
Error:  
Error:          /home/runner/work/cobot/cobot/node_modules/@prettier/plugin-ruby/dist/parser/getInfo.js:8
Error:    throw new Error("Failed to get information from parse server in time.");
Error:    ^
Error:  
Error:  Error: Failed to get information from parse server in time.
Error:      at Timeout._onTimeout (/home/runner/work/cobot/cobot/node_modules/@prettier/plugin-ruby/dist/parser/getInfo.js:8:9)
Error:      at listOnTimeout (internal/timers.js:557:17)
Error:      at processTimers (internal/timers.js:500:7)
Error:  .
Error:      
Error:      at spawnServer (/home/runner/work/cobot/cobot/node_modules/@prettier/plugin-ruby/dist/parser/parseSync.js:133:15)
Error:      at parseSync (/home/runner/work/cobot/cobot/node_modules/@prettier/plugin-ruby/dist/parser/parseSync.js:155:22)
Error:      at Object.parse (/home/runner/work/cobot/cobot/node_modules/@prettier/plugin-ruby/dist/ruby/parser.js:13:40)
Error:      at Object.parse$d [as parse] (/home/runner/work/cobot/cobot/node_modules/prettier/index.js:12975:19)
Error:      at coreFormat (/home/runner/work/cobot/cobot/node_modules/prettier/index.js:14525:16)
Error:      at formatWithCursor$1 (/home/runner/work/cobot/cobot/node_modules/prettier/index.js:14765:14)
Error:      at Object.formatWithCursor (/home/runner/work/cobot/cobot/node_modules/prettier/index.js:60955:12)
Error:      at format$1 (/home/runner/work/cobot/cobot/node_modules/prettier/bin-prettier.js:18001:21)
Error:      at Object.formatFiles$1 [as formatFiles] (/home/runner/work/cobot/cobot/node_modules/prettier/bin-prettier.js:18115:16)
Error:      at async main (/home/runner/work/cobot/cobot/node_modules/prettier/bin-prettier.js:20216:5)
All matched files use Prettier code style!
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.
jamesrweb commented 2 years ago

I am having the same error on Windows 10 (latest build) when running prettier . --write using default options. Both ruby and node are in the PATH and on the latest versions. All other prettier plugins I am using work just fine, this plugin just crashes on every single run. Anyone got some idea what could be causing the issue?

burabure commented 2 years ago

Same issue here.

ErrolynM commented 2 years ago

I am also running into a similar issue. When I run it from the command line it works 99% of the time but when it is ran from the plugin in VS code I get the failed to spawn the parser sever 100% of the time.

Operating system: Arch Linux; Build ID: rolling Ruby version: 2.7.5 Node version: 14.18.1 @prettier/plugin-ruby or prettier gem version: 2.5.0

kddnewton commented 2 years ago

Hey @langalex thanks for the report. I'm adding a PRETTIER_RUBY_TIMEOUT_MS environment variable for the next release. Test it out and let me know how it goes.