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

vscode升级到1.32.1后,debug启动时代码卡住,无法启动 #3534

Closed
lixiaolihua opened this issue Mar 12, 2019 · 18 comments
Closed

Comments

@lixiaolihua
Copy link

vscode升级到1.32.1后,debug启动时代码卡住,无法启动

只有升级到vscode1.32.1才会有问题,周围同事不升级可以启动,升级后也启动不了了...

image

@atian25
Copy link
Member

atian25 commented Mar 12, 2019

从截图来看, master 启动成功了,也被 attach 了。
然后 agent 启动,在 5800 启动调试端口,但一直没有 attach。
说明 `autoAttachChildProcesses: true' 这个 vscode 配置似乎没生效。

具体为何没生效,就不知道了,这属于 VSCode 调试 Node 的问题了,跟 Egg 这层关系不大。

我本地同样的版本,无法复现。参见最后的回复:
atian25/blog#25 (comment)

临时解决方案:如果你不需要调试启动期的代码,直接把 inspect-brk 干掉。

@lixiaolihua
Copy link
Author

刚刚用 egg-init egg-example --type=simple 初始化了一个工程,直接启动,也会卡住

image

@atian25
Copy link
Member

atian25 commented Mar 12, 2019

贴下你的 launch.json

@lixiaolihua
Copy link
Author

@atian25

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Egg Debug",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run",
        "debug",
        "--",
        "--inspect-brk"
      ],
      "console": "integratedTerminal",
      "restart": true,
      "protocol": "auto",
      "port": 9229,
      "autoAttachChildProcesses": true
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Egg Test",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run",
        "test-local",
        "--",
        "--inspect-brk"
      ],
      "protocol": "auto",
      "port": 9229,
      "autoAttachChildProcesses": true
    },
    {
      "type": "node",
      "request": "attach",
      "name": "Egg Attach to remote",
      "localRoot": "${workspaceRoot}",
      "remoteRoot": "/usr/src/app",
      "address": "localhost",
      "protocol": "auto",
      "port": 9999
    }
  ]
}

@atian25
Copy link
Member

atian25 commented Mar 12, 2019

好的,我看看。

@atian25
Copy link
Member

atian25 commented Mar 12, 2019

试了下,没能复现。 T_T

@atian25
Copy link
Member

atian25 commented Mar 12, 2019

@lixiaolihua 我这边偶发会触发,不确定是不是 VSCode 自己的 Bug,当卡住的时候:

F1 -> Debug: attach to node process -> 选择 5800 那一条,就能下去了。

感觉是 VSCode 检测子进程这里有问题,但我这复现频率不高。

你现在可以选择其中一种解决方式:

  • 大部分情况下,不要 --inspect-brk 就好了。
  • 选择 auto attach 的调试方式。

@lixiaolihua
Copy link
Author

好的,3Q。

@lixiaolihua
Copy link
Author

貌似是vscode的问题
microsoft/vscode#70243

@atian25
Copy link
Member

atian25 commented Mar 12, 2019

感谢反馈~

@gogogo1024
Copy link

gogogo1024 commented Mar 28, 2019

同样的情况,有时候会成功个几次,成功的时候会在agent_work.js,app_worker.js出现断点,得自己手动点击跳过断点才能继续下去。

@JsonMa
Copy link

JsonMa commented Jul 2, 2019

@atian25 去掉 --inspect-brk 确实能解决这个问题。

@atian25
Copy link
Member

atian25 commented Oct 9, 2019

。。。 不要乱猜

egg master -- 9229
egg agent -- 5800
egg worker1 -- 9230

@datouxia
Copy link

datouxia commented Oct 10, 2019

。。。 不要乱猜

egg master -- 9229
egg agent -- 5800
egg worker1 -- 9230

之前认为是端口号的问题,是我搞错了。感谢@atian25指出问题。

但是我现在找到了稳定重现和临时解决问题的方式,我是Mac OS 10.14.6可以重现,大家可以试试看:

根据快速入门初始化一个空项目;
去VSCode下载最新版本1.38.1 Stable版本安装;
在VSCode中安装eggjs 0.3.1扩展;
在VSCode中打开初始化空项目,新增Egg调试配置,直接运行,卡住了。

怀疑是TS引起的,所以自己摸索出了临时解决方式:
打开package.json找到:

"egg": {
"declarations": true
},
修改为

"egg": {
"declarations": false
},
重新运行,又恢复到之前的丝般顺滑体验。

@atian25
Copy link
Member

atian25 commented Oct 10, 2019

额。。。感谢反馈,我们看下,有可能是 egg-ts-helper fork 的进程也接收了 brk 这个参数,导致阻塞了,cc @whxaxes

@wizzeng
Copy link

wizzeng commented Jan 7, 2020

@datouxia 解决,同 Macos 10.15.2 + VS Code 1.41.1

@yoyokko
Copy link

yoyokko commented Jan 16, 2020

额。。。感谢反馈,我们看下,有可能是 egg-ts-helper fork 的进程也接收了 brk 这个参数,导致阻塞了,cc @whxaxes

我这边是vscode第一次打开,调试没问题,第二次之后就稳定卡死。看了进程取样确实是三个进程都在等待信号

日志供参考
启动日志,卡死不动,查看相关三个进程pid
eggjs-pidlist.txt

egg-bin进程取样
eggjs-egg-bin.txt

agentworker进程取样
eggjs-agnet_worker.txt

start-cluester进程取样
eggjs-start-cluster.txt

@atian25
Copy link
Member

atian25 commented Jan 16, 2020

去掉 brk 吧

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

7 participants