egg-development-proxyworker
v1.2.0
Published
A proxy worker for debugging worker on egg.
Downloads
46
Readme
egg-development-proxyworker
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
npm i egg-development-proxyworker --save
2. Enable the plugin
// config/plugin.js
exports.proxyworker = {
enable: true,
package: 'egg-development-proxyworker',
};
// config/config.default.js
// If 10086 is occupied, you can specify the other port number through this configuration
exports.proxyworker = {
port: 10086,
};
3. Add debug configuration in .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Egg",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run", "dev", "--", "--debug"
],
"port": 5858
},
{
"name": "Attach Agent",
"type": "node",
"request": "attach",
"port": 5856
},
{
"name": "Attach Worker",
"type": "node",
"request": "attach",
"restart": true,
"port": 10086
}
],
"compounds": [
{
"name": "Debug Egg",
"configurations": ["Launch Egg", "Attach Agent", "Attach Worker"]
}
]
}
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:
- Support very large JavaScript object
- Support ES6 Proxy
- 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:
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.