首页 > 解决方案 > VSCode 不会关闭子进程 (processChild.js)

问题描述

我刚刚注意到,在关闭调试器后,VSCode 并没有按应有的方式关闭 Node.js 子进程。在调试器启动/停止 5-10 次后,这些进程开始严重占用我的内存。

我正在使用最新的 LTS nodejs 来管理NVM

我不知道我的调试器配置或 VSCode 错误是否有问题,但这是我的配置;

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch via yarn",
      "request": "launch",
      "runtimeArgs": [
        "run",
        "dev"
      ],
      "runtimeExecutable": "yarn",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "type": "pwa-node"
    },
    {
      "name": "Node Attach",
      "port": 9229,
      "request": "attach",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "type": "pwa-node"
    },
    {
      "type": "firefox",
      "request": "launch",
      "reAttach": true,
      "name": "Launch firefox",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}",
      "pathMappings": [
        {
          "url": "webpack://_n_e/pages/news",
          "path": "${workspaceFolder}/pages/news"
        },
        {
          "url": "webpack://_n_e/client/index.tsx",
          "path": "${workspaceFolder}/pages/news/index.tsx"
        },
        {
          "url": "webpack://_n_e/pages/haberler",
          "path": "${workspaceFolder}/pages/haberler"
        },
        {
          "url": "webpack://_n_e/components",
          "path": "${workspaceFolder}/components"
        }
      ]
    }
  ],
  "compounds": [
    {
      "name": "Combined debugger",
      "configurations": ["Launch via yarn", "Node Attach", "Launch firefox"]
    }
  ]
}

标签: node.jsvisual-studio-codevscode-debuggernvm

解决方案


我发现只有在Launch via yarn关闭之前关闭才会出现问题Node Attach

为了防止关闭顺序出现错误,我删除了Node Attach支持自动附加功能的配置。

这是我的配置的最新版本,供需要的人使用;

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch via yarn",
      "request": "launch",
      "runtimeArgs": [
        "run",
        "dev"
      ],
      "runtimeExecutable": "yarn",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "type": "pwa-node",
      "console": "integratedTerminal"
    },
    {
      "type": "firefox",
      "request": "launch",
      "reAttach": true,
      "name": "Launch firefox",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}",
      "pathMappings": [
        {
          "url": "webpack://_n_e/client/index.tsx",
          "path": "${workspaceFolder}/pages/index.tsx"
        },
        {
          "url": "webpack://_n_e/components",
          "path": "${workspaceFolder}/components"
        }
      ]
    }
  ],
  "compounds": [
    {
      "name": "Combined debugger",
      "configurations": ["Launch via yarn", "Launch firefox"]
    }
  ]
}

推荐阅读