项目作者: eggjs

项目描述 :
**[DEPRECATED]** A proxy worker for debugging worker on egg
高级语言: JavaScript
项目地址: git://github.com/eggjs/egg-development-proxyworker.git
创建时间: 2017-03-30T04:00:06Z
项目社区:https://github.com/eggjs/egg-development-proxyworker

开源协议:MIT License

下载


egg-development-proxyworker

NPM version
build status
Test coverage
David deps
Known Vulnerabilities
npm download

A proxy worker for debugging worker on egg

DEPRECATED, use egg-bin debug instead.

As in development stage, when we modify the code and save, the application will automatically restart the worker. But every time the worker’s updates make the debug port change, And VSCode is required to attach to a fixed debug port. So we enabled a proxy service called proxyworker. Worker debugging information will be proxied to this service. And then VSCode through the fixed attach to proxyworker to debug the worker

The following are the installation steps:

1. Install egg-development-proxyworker plugin
  1. npm i egg-development-proxyworker --save
2. Enable the plugin
  1. // config/plugin.js
  2. exports.proxyworker = {
  3. enable: true,
  4. package: 'egg-development-proxyworker',
  5. };
  6. // config/config.default.js
  7. // If 10086 is occupied, you can specify the other port number through this configuration
  8. exports.proxyworker = {
  9. port: 10086,
  10. };
3. Add debug configuration in .vscode/launch.json :
  1. {
  2. "version": "0.2.0",
  3. "configurations": [
  4. {
  5. "name": "Launch Egg",
  6. "type": "node",
  7. "request": "launch",
  8. "cwd": "${workspaceRoot}",
  9. "runtimeExecutable": "npm",
  10. "windows": {
  11. "runtimeExecutable": "npm.cmd"
  12. },
  13. "runtimeArgs": [
  14. "run", "dev", "--", "--debug"
  15. ],
  16. "port": 5858
  17. },
  18. {
  19. "name": "Attach Agent",
  20. "type": "node",
  21. "request": "attach",
  22. "port": 5856
  23. },
  24. {
  25. "name": "Attach Worker",
  26. "type": "node",
  27. "request": "attach",
  28. "restart": true,
  29. "port": 10086
  30. }
  31. ],
  32. "compounds": [
  33. {
  34. "name": "Debug Egg",
  35. "configurations": ["Launch Egg", "Attach Agent", "Attach Worker"]
  36. }
  37. ]
  38. }

As V8 Debugger Legacy Protocol will be removed after Node.js 8.x, And replace the use of Inspector Protocol

The new protocol has three major advantages:

  1. Support very large JavaScript object
  2. Support ES6 Proxy
  3. Support Source Map better

For and only for Node.js >= 7.x we should use Inspector Protocol for debugging.

In the above debug configuration, you need to modify some parameters to open the new protocol:

  • Launch Egg adjust the parameter "runtimeArgs": ["run", "debug"]
  • Attach Worker add the parameter "protocol": "inspector"

In addition, if you use the new protocol can also use chrome devtools for debugging, debugging address:

  1. chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:10087
4. Start debugging

In VSCode, switch to the debug page. Select the Debug Egg configuration to start.

More VSCode Debug usage can be found in the documentation: Node.js Debugging in VS Code

Questions & Suggestions

Please open an issue here.

License

MIT