Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails server terminates threads when debugging without WEB_CONCURRENCY=0 #318

Open
tohagan opened this issue Dec 18, 2021 · 0 comments
Open

Comments

@tohagan
Copy link

tohagan commented Dec 18, 2021

VS Code 1.63.2 / Rails 6.0.4 / Puma gem 4.3

I'm running Rails and VSCode with WSL 1.0 with Ubuntu 20.04.
I start up VSCode with WSL. 1.0 (WSL 2.0 had network routing problems for me).

If WEB_CONCURRENCY > 0 via config/puma.rb, Puma will run in cluster mode with multiple concurrent worker threads and terminate them if they appear to be not returning a response after a timeout period. When debugging in a worker thread I observe that breakpoints work, I make a few steps in the code and then the debugger stops responding at all. A log message indicates that Puma has terminated a worker thread. This commonly occurs with breakpoints set or even if just running slower with a large app running in the debugger.

This is fixed by setting WEB_CONCURRENCY=0.

So I'd recommend adding the following to Debug Rails Server launch.json ...

"env": {
  "WEB_CONCURRENCY": "0"
}

Here's my complete config for Debug Rails server ...

{
  "name": "Debug Rails server",
  "type": "Ruby",
  "request": "launch",
  "cwd": "${workspaceRoot}",
  "useBundler": true,
  "pathToBundler": "/path/to/rubygem/wrappers/bundle",
  "pathToRDebugIDE": "/path/to/rubygem/gems/ruby-debug-ide-x.x.x/bin/rdebug-ide",
  "program": "${workspaceRoot}/bin/rails",
  "args": [
    "server",
    "-p",
    "3000"
  ],
  "env": {
    "WEB_CONCURRENCY": "0"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant