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

fix: should not timeout when debugging #129

Merged
merged 2 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cmd/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DebugCommand extends Command {
proxy.start({ debugPort }).then(() => {
// don't log within VSCode and WebStorm
// TODO: don't start proxy within vscode and webstorm at next major
if (!process.env.VSCODE_CLI && !process.env.NODE_DEBUG_OPTION) {
if (!process.env.VSCODE_CLI && !process.env.NODE_DEBUG_OPTION && !process.env.JB_DEBUG_FILE) {
console.log(chalk.yellow(`Debug Proxy online, now you could attach to ${proxyPort} without worry about reload.`));
if (newDebugger) console.log(chalk.yellow(`DevTools → ${proxy.url}`));
}
Expand Down
7 changes: 5 additions & 2 deletions lib/cmd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ class TestCommand extends Command {
* @return {Array} [ '--require=xxx', 'xx.test.js' ]
* @protected
*/
* formatTestArgs({ argv, debug }) {
* formatTestArgs({ argv, debugOptions }) {
// whether is debug mode, if pass --inspect then `debugOptions` is valid
// others like WebStorm 2019 will pass NODE_OPTIONS, and egg-bin itself will be debug, so could detect `process.debugPort`.
const isDebugging = debugOptions || process.debugPort;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebStorm 2018 的时候,会传递 NODE_DEBUG_OPTIONS,在 common-bin 会处理转换为 debugOptions。

但最新的 WebStorm 2019,换了实现方式,是会传递 NODE_OPTIONS = --require= 的方式,导致无法分析出。

由于我们一般都是 npm run 的方式去调试的,因此在 WebStorm 里面,egg-bin 本身也是会 debug 的,因此可以通过读取 egg-bin 本身有没有 debugPort 来判断当前是不是在 debug 模式

const testArgv = Object.assign({}, argv);

/* istanbul ignore next */
Expand All @@ -83,7 +86,7 @@ class TestCommand extends Command {
// force exit
testArgv.exit = true;

if (debug) {
if (isDebugging) {
// --no-timeouts
testArgv.timeouts = false;
testArgv.timeout = undefined;
Expand Down
11 changes: 11 additions & 0 deletions test/lib/cmd/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,16 @@ describe('test/lib/cmd/debug.test.js', () => {
.expect('code', 0)
.end();
});

it('should not print devtools at webstorm 2019', function* () {
mm(process.env, 'JB_DEBUG_FILE', __filename);
const app = coffee.fork(eggBin, [ 'debug' ], { cwd });
// app.debug();
yield app.expect('stderr', /Debugger listening/)
.notExpect('stdout', /Debug Proxy online, now you could attach to 9999/)
.notExpect('stdout', /DevTools → chrome-devtools:.*:9999/)
.expect('code', 0)
.end();
});
});
});