From b52cde7fd4af34f595dfa8e2488e84523a898b17 Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 17:01:23 +0800 Subject: [PATCH 1/7] feat: start ensure no stderr, so open --trace-warnings will helpful for debug --- lib/cmd/start.js | 1 + test/fixtures/example/app.js | 8 ++++++++ test/start.test.js | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/cmd/start.js b/lib/cmd/start.js index 8445a63..add1e2a 100644 --- a/lib/cmd/start.js +++ b/lib/cmd/start.js @@ -131,6 +131,7 @@ class StartCommand extends Command { // additional execArgv execArgvObj.deprecation = false; // --no-deprecation + execArgvObj.traceWarnings = true; // --trace-warnings const command = argv.node || 'node'; diff --git a/test/fixtures/example/app.js b/test/fixtures/example/app.js index bbebd92..2cec84a 100644 --- a/test/fixtures/example/app.js +++ b/test/fixtures/example/app.js @@ -1,6 +1,14 @@ 'use strict'; +const Event = require('events'); +const event = new Event(); +event.setMaxListeners(1); + module.exports = () => { // --no-deprecation new Buffer('aaa'); + + // --trace-warnings test about MaxListenersExceededWarning + event.on('xx', () => {}); + event.on('xx', () => {}); }; diff --git a/test/start.test.js b/test/start.test.js index d7b217c..d00881c 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -112,7 +112,8 @@ describe('test/start.test.js', () => { yield sleep(waitTime); - assert(app.stderr === ''); + assert(app.stderr.includes('MaxListenersExceededWarning:')); + assert(app.stderr.includes('app.js:13:9')); // should had trace assert(!app.stdout.includes('DeprecationWarning:')); assert(app.stdout.includes('--title=egg-server-example')); assert(app.stdout.includes('"title":"egg-server-example"')); From 2c0ccb3836b9eb0ead5619714dd72d7689a2752b Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 17:10:39 +0800 Subject: [PATCH 2/7] test: ci16 --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 05760f6..035aae3 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [12, 14] + node-version: [12, 14, 16] os: [ubuntu-latest, windows-latest, macos-latest] steps: From 88244b2487b177e00bd6adc365af2b8fcb82808b Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 17:20:20 +0800 Subject: [PATCH 3/7] chore: github action --- .github/workflows/nodejs.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 035aae3..b913cce 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -5,9 +5,11 @@ name: Node.js CI on: push: - branches: [ master ] + branches: + - master pull_request: - branches: [ master ] + branches: + - master schedule: - cron: '0 2 * * *' From 9fd2b5b0cb03777e3a4d47fbab40c4e557c337e4 Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 17:37:37 +0800 Subject: [PATCH 4/7] test: fix testcase --- test/fixtures/example/app.js | 8 -------- test/fixtures/trace-warnings/app.js | 14 ++++++++++++++ test/fixtures/trace-warnings/package.json | 4 ++++ test/start.test.js | 14 ++++++++++++-- 4 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/trace-warnings/app.js create mode 100644 test/fixtures/trace-warnings/package.json diff --git a/test/fixtures/example/app.js b/test/fixtures/example/app.js index 2cec84a..bbebd92 100644 --- a/test/fixtures/example/app.js +++ b/test/fixtures/example/app.js @@ -1,14 +1,6 @@ 'use strict'; -const Event = require('events'); -const event = new Event(); -event.setMaxListeners(1); - module.exports = () => { // --no-deprecation new Buffer('aaa'); - - // --trace-warnings test about MaxListenersExceededWarning - event.on('xx', () => {}); - event.on('xx', () => {}); }; diff --git a/test/fixtures/trace-warnings/app.js b/test/fixtures/trace-warnings/app.js new file mode 100644 index 0000000..2cec84a --- /dev/null +++ b/test/fixtures/trace-warnings/app.js @@ -0,0 +1,14 @@ +'use strict'; + +const Event = require('events'); +const event = new Event(); +event.setMaxListeners(1); + +module.exports = () => { + // --no-deprecation + new Buffer('aaa'); + + // --trace-warnings test about MaxListenersExceededWarning + event.on('xx', () => {}); + event.on('xx', () => {}); +}; diff --git a/test/fixtures/trace-warnings/package.json b/test/fixtures/trace-warnings/package.json new file mode 100644 index 0000000..dfc4b17 --- /dev/null +++ b/test/fixtures/trace-warnings/package.json @@ -0,0 +1,4 @@ +{ + "name": "trace-warnings", + "version": "1.0.0" +} diff --git a/test/start.test.js b/test/start.test.js index d00881c..d1c6ee9 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -112,8 +112,7 @@ describe('test/start.test.js', () => { yield sleep(waitTime); - assert(app.stderr.includes('MaxListenersExceededWarning:')); - assert(app.stderr.includes('app.js:13:9')); // should had trace + assert(app.stderr === ''); assert(!app.stdout.includes('DeprecationWarning:')); assert(app.stdout.includes('--title=egg-server-example')); assert(app.stdout.includes('"title":"egg-server-example"')); @@ -124,6 +123,17 @@ describe('test/start.test.js', () => { assert(result.data.toString() === 'hi, egg'); }); + it('should start --trace-warnings work', function* () { + app = coffee.fork(eggBin, [ 'start', '--workers=1', path.join(__dirname, 'fixtures/trace-warnings') ]); + app.debug(); + app.expect('code', 0); + + yield sleep(waitTime); + + assert(app.stderr.includes('MaxListenersExceededWarning:')); + assert(app.stderr.includes('app.js:13:9')); // should had trace + }); + it.skip('should get ready', function* () { app = coffee.fork(path.join(__dirname, './fixtures/ipc-bin/start.js'), [], { env: { From 3eeaa9f5707a2eb78a7e2123748a004c10d7cc26 Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 17:39:25 +0800 Subject: [PATCH 5/7] test: add --no-deprecation effect test --- test/fixtures/trace-warnings/app.js | 6 +++--- test/start.test.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/fixtures/trace-warnings/app.js b/test/fixtures/trace-warnings/app.js index 2cec84a..9eee040 100644 --- a/test/fixtures/trace-warnings/app.js +++ b/test/fixtures/trace-warnings/app.js @@ -5,10 +5,10 @@ const event = new Event(); event.setMaxListeners(1); module.exports = () => { - // --no-deprecation - new Buffer('aaa'); - // --trace-warnings test about MaxListenersExceededWarning event.on('xx', () => {}); event.on('xx', () => {}); + + // will not effect --no-deprecation argv + new Buffer('aaa'); }; diff --git a/test/start.test.js b/test/start.test.js index d1c6ee9..cd1409a 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -132,6 +132,7 @@ describe('test/start.test.js', () => { assert(app.stderr.includes('MaxListenersExceededWarning:')); assert(app.stderr.includes('app.js:13:9')); // should had trace + assert(!app.stdout.includes('DeprecationWarning:')); }); it.skip('should get ready', function* () { From 30cd5834ae753df106b218eecc1b4c6c0685428f Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 17:58:35 +0800 Subject: [PATCH 6/7] fix: testcase --- test/stop.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/stop.test.js b/test/stop.test.js index 95fe485..f15560c 100644 --- a/test/stop.test.js +++ b/test/stop.test.js @@ -64,7 +64,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[app_worker] exit with code:0')); // assert(app.stdout.includes('[agent_worker] exit with code:0')); @@ -106,7 +106,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(stdout.includes('[master] receive signal SIGTERM, closing')); + assert(stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(stdout.includes('[master] exit with code:0')); assert(stdout.includes('[app_worker] exit with code:0')); } @@ -191,7 +191,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[app_worker] exit with code:0')); // assert(app.stdout.includes('[agent_worker] exit with code:0')); @@ -248,7 +248,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[app_worker] exit with code:0')); // assert(app.stdout.includes('[agent_worker] exit with code:0')); @@ -261,7 +261,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app2.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app2.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app2.stdout.includes('[master] exit with code:0')); assert(app2.stdout.includes('[app_worker] exit with code:0')); } @@ -275,7 +275,7 @@ describe('test/stop.test.js', () => { beforeEach(function* () { yield utils.cleanup(timeoutPath); app = coffee.fork(eggBin, [ 'start', '--workers=2', '--title=stop-timeout', timeoutPath ]); - // app.debug(); + app.debug(); app.expect('code', 0); yield sleep(waitTime); @@ -304,7 +304,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.match(/app_worker#\d+:\d+ disconnect/)); assert(app.stdout.match(/don't fork, because worker:\d+ will be kill soon/)); } @@ -326,7 +326,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[agent_worker] exit with code:0')); } From 38a2f91f9b46c7011a11d713390cfec8a685f95b Mon Sep 17 00:00:00 2001 From: mansonchor Date: Sun, 27 Mar 2022 18:15:30 +0800 Subject: [PATCH 7/7] fix: testcase --- test/start.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/start.test.js b/test/start.test.js index cd1409a..ca22a4b 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -131,7 +131,7 @@ describe('test/start.test.js', () => { yield sleep(waitTime); assert(app.stderr.includes('MaxListenersExceededWarning:')); - assert(app.stderr.includes('app.js:13:9')); // should had trace + assert(app.stderr.includes('app.js:10:9')); // should had trace assert(!app.stdout.includes('DeprecationWarning:')); });