Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.4k stars 128 forks source link

Stack level too deep error on indexing project with docusign_esign gem dependency #2095

Open Galathius opened 1 month ago

Galathius commented 1 month ago

Description

Recently tried to switch from my previous IDE to vscode using ruby-lsp extension. On one of my project, I got the indexing process stuck with the message Ruby LSP: indexing files: 33% completed.

Checking Output tab led me to Stack level too deep error:

Logs 2024-05-29 14:59:19.596 [info] (hireglobal-backend) # terminated with exception (report_on_exception is true): 2024-05-29 14:59:19.601 [info] (hireglobal-backend) /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `each': stack level too deep (SystemStackError) from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `visit_child_nodes' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:97:in `visit_and_node' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/node.rb:537:in `accept' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `block in visit_child_nodes' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `each' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/visitor.rb:31:in `visit_child_nodes' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/dispatcher.rb:97:in `visit_and_node' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/prism-0.29.0/lib/prism/node.rb:537:in `accept' ... 3605 levels... from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.16.7/lib/ruby_indexer/lib/ruby_indexer/index.rb:175:in `index_all' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11262/lib/types/private/methods/_methods.rb:279:in `bind_call' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11262/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added' from /Users/galathius/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-0.16.7/lib/ruby_lsp/server.rb:693:in `block in perform_initial_indexing'

Then I went through these instrucitons and figured out that it's failing on 7k LOC file from docusign_ruby gem.

I was managed to fix it by adding .index.yml file to the root of my project with the following content:

excluded_gems:
  - docusign_esign

Not sure how common this problem is, but I’m afraid it may stop some people from switching to VS Code and from using ruby-lsp. Maybe it is worth handling such error-prone cases somehow.

andyw8 commented 1 month ago

Thanks for the report. I'm trying to reproduce this failure but not seeing it yet, what version of the docusign_esign gem are you using?

Galathius commented 1 month ago

Hi @andyw8! Here are details:

andyw8 commented 1 month ago

Thanks, I was able to reproduce on Ruby 3.2.2, it's fine on 3.3.1

FYI @kddnewton

andyw8 commented 1 month ago

(one thing I don't yet understand is why ruby-lsp-doctor doesn't fail for this...)

andyw8 commented 1 month ago

Possible fix/workaround: https://github.com/Shopify/ruby-lsp/pull/2097