Skip to content

Commit 07f7815

Browse files
committed
Handle closed channels and upgrade dependencies
1 parent 4effab6 commit 07f7815

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## v0.1.3
2+
* Fix Cannot read property 'mtime' of undefined on OSX
3+
4+
## v0.1.2
5+
* Workers mode works correctly (fixed typo)
6+
7+
## v0.1.1
8+
* Support memory limit in multi-process mode
9+
* Handle already closed channel case on sending ipc message
10+
11+
## v0.1.0
12+
* Initial release - not production ready.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ This plugin provides some custom webpack hooks (all are sync):
9494
|`fork-ts-checker-cancel`| Cancellation has been requested | `cancellationToken` |
9595
|`fork-ts-checker-waiting`| Waiting for results | `hasTsLint` |
9696
|`fork-ts-checker-service-start`| Service will be started | `tsconfigPath`, `tslintPath`, `watchPaths`, `workersNumber`, `memoryLimit` |
97+
|`fork-ts-checker-service-start-error` | Cannot start service | `error` |
9798
|`fork-ts-checker-service-out-of-memory`| Service is out of memory | - |
9899
|`fork-ts-checker-receive`| Plugin receives diagnostics and lints from service | `diagnostics`, `lints` |
99100
|`fork-ts-checker-emit`| Service will add errors and warnings to webpack compilation (`blockEmit: true`) | `diagnostics`, `lints`, `elapsed` |

lib/cluster.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ var result = new WorkResult(pids);
2929
process.on('message', function (message) {
3030
// broadcast message to all workers
3131
workers.forEach(function (worker) {
32-
worker.send(message);
32+
try {
33+
worker.send(message);
34+
} catch (e) {
35+
// channel closed - something went wrong - close cluster...
36+
process.exit();
37+
}
3338
});
3439

3540
// clear previous result set

lib/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,16 @@ ForkTsCheckerWebpackPlugin.prototype.pluginCompile = function () {
156156
if (!this.service || !this.service.connected) {
157157
this.spawnService();
158158
}
159-
this.service.send(this.cancellationToken);
159+
160+
try {
161+
this.service.send(this.cancellationToken);
162+
} catch (error) {
163+
if (!this.options.silent && this.logger) {
164+
this.logger.error(this.colors.red('Cannot start checker service: ' + (error ? error.toString() : 'Unknown error')));
165+
}
166+
167+
this.compiler.applyPlugins('fork-ts-checker-service-start-error', error);
168+
}
160169
}.bind(this));
161170
};
162171

package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
"chai": "^3.5.0",
3535
"eslint": "^3.19.0",
3636
"istanbul": "^0.4.5",
37-
"mocha": "^3.2.0",
38-
"mock-fs": "^4.2.0",
37+
"mocha": "^3.4.1",
38+
"mock-fs": "^4.3.0",
3939
"mock-require": "^2.0.2",
4040
"rimraf": "^2.5.4",
41-
"sinon": "^2.1.0",
41+
"sinon": "^2.2.0",
4242
"typescript": "^2.1.0"
4343
},
4444
"peerDependencies": {
@@ -47,12 +47,9 @@
4747
},
4848
"dependencies": {
4949
"chalk": "^1.1.3",
50-
"chokidar": "^1.6.1",
50+
"chokidar": "^1.7.0",
5151
"lodash.endswith": "^4.2.1",
5252
"lodash.isstring": "^4.0.1",
5353
"lodash.startswith": "^4.2.1"
54-
},
55-
"optionalDependencies": {
56-
"tslint": "^5.0.0"
5754
}
5855
}

yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
249249
strip-ansi "^3.0.0"
250250
supports-color "^2.0.0"
251251

252-
chokidar@^1.6.1:
253-
version "1.6.1"
254-
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2"
252+
chokidar@^1.7.0:
253+
version "1.7.0"
254+
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
255255
dependencies:
256256
anymatch "^1.3.0"
257257
async-each "^1.0.0"
@@ -1232,9 +1232,9 @@ [email protected], [email protected], "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1:
12321232
dependencies:
12331233
minimist "0.0.8"
12341234

1235-
mocha@^3.2.0:
1236-
version "3.3.0"
1237-
resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.3.0.tgz#d29b7428d3f52c82e2e65df1ecb7064e1aabbfb5"
1235+
mocha@^3.4.1:
1236+
version "3.4.1"
1237+
resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.4.1.tgz#a3802b4aa381934cacb38de70cf771621da8f9af"
12381238
dependencies:
12391239
browser-stdout "1.3.0"
12401240
commander "2.9.0"
@@ -1248,9 +1248,9 @@ mocha@^3.2.0:
12481248
mkdirp "0.5.1"
12491249
supports-color "3.1.2"
12501250

1251-
mock-fs@^4.2.0:
1252-
version "4.2.0"
1253-
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.2.0.tgz#ef53ae17b77e64f67816dd0467f29208a3b26e19"
1251+
mock-fs@^4.3.0:
1252+
version "4.3.0"
1253+
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.3.0.tgz#c2fab8d784283287e9b6ae7538f2dc56c1a05ed7"
12541254

12551255
mock-require@^2.0.2:
12561256
version "2.0.2"
@@ -1638,9 +1638,9 @@ signal-exit@^3.0.0:
16381638
version "3.0.2"
16391639
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
16401640

1641-
sinon@^2.1.0:
1642-
version "2.1.0"
1643-
resolved "https://registry.yarnpkg.com/sinon/-/sinon-2.1.0.tgz#e057a9d2bf1b32f5d6dd62628ca9ee3961b0cafb"
1641+
sinon@^2.2.0:
1642+
version "2.2.0"
1643+
resolved "https://registry.yarnpkg.com/sinon/-/sinon-2.2.0.tgz#3b1b42ff5defcbf51a52a62aca6d61171b9fd262"
16441644
dependencies:
16451645
diff "^3.1.0"
16461646
formatio "1.2.0"

0 commit comments

Comments
 (0)