fix: handle a potential uncaughtException#113
Merged
shellscape merged 1 commit intoshellscape:masterfrom Feb 20, 2019
Merged
Conversation
Fixes a case in which we tried to send data through a socket that isn't connected due to the client being in the middle of a page reload (and thus closing the connection). This exception killed the whole webpack process.
Example stacktrace:
```
uncaughtException Error: WebSocket is not open: readyState 2 (CLOSING)
at WebSocket.send (/app/node_modules/ws/lib/websocket.js:322:19)
at WebpackPluginServe.socket.progress (/app/node_modules/webpack-plugin-serve/lib/routes.js:87:16)
at WebpackPluginServe.emit (events.js:189:13)
at ProgressPlugin (/app/node_modules/webpack-plugin-serve/lib/index.js:212:16)
at update (/app/node_modules/webpack/lib/ProgressPlugin.js:151:5)
at moduleAdd (/app/node_modules/webpack/lib/ProgressPlugin.js:163:5)
at SyncHook.eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:11:1)
at Compilation.buildModule (/app/node_modules/webpack/lib/Compilation.js:634:26)
at factory.create (/app/node_modules/webpack/lib/Compilation.js:884:14)
at factory (/app/node_modules/webpack/lib/NormalModuleFactory.js:405:6)
at hooks.afterResolve.callAsync (/app/node_modules/webpack/lib/NormalModuleFactory.js:155:13)
at AsyncSeriesWaterfallHook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:6:1)
at resolver (/app/node_modules/webpack/lib/NormalModuleFactory.js:138:29)
at process.nextTick (/app/node_modules/webpack/lib/NormalModuleFactory.js:342:9)
at process._tickCallback (internal/process/next_tick.js:61:11)
```
shellscape
reviewed
Feb 18, 2019
| }; | ||
|
|
||
| socket.progress = (data) => { | ||
| if (socket.readyState !== 1) { |
Owner
There was a problem hiding this comment.
I'm good with the change. But it begs the question: should we wrap socket.send and inject that same logical check so all attempts to socket.send are covered?
Contributor
Author
There was a problem hiding this comment.
That sounds reasonable, it should prevent any other such problems. I'll look into it.
Owner
|
Going to merge this for now as it fixes a real problem. We can circle back to a more comprehensive fix later on. |
Contributor
Author
|
Thanks @shellscape! |
niieani
added a commit
to niieani/webpack-plugin-serve
that referenced
this pull request
Apr 29, 2019
Follow up to shellscape#113. Even with the above fix, I encountered a similar issue, this time in the `invalid` handler: ``` uncaughtException Error: WebSocket is not open: readyState 2 (CLOSING) at WebSocket.send (/app/node_modules/webpack-plugin-serve/node_modules/ws/lib/websocket.js:322:19) at WebpackPluginServe.socket.invalid (/app/node_modules/webpack-plugin-serve/lib/routes.js:83:16) at WebpackPluginServe.emit (events.js:189:13) at invalid.tap (/app/node_modules/webpack-plugin-serve/lib/index.js:155:41) at SyncHook.eval (eval at create (/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1) at Watchpack.watcher.compiler.watchFileSystem.watch (/app/node_modules/webpack/lib/Watching.js:139:33) at Object.onceWrapper (events.js:277:13) at Watchpack.emit (events.js:189:13) at Watchpack._onChange (/app/node_modules/watchpack/lib/watchpack.js:118:7) at Watchpack.<anonymous> (/app/node_modules/watchpack/lib/watchpack.js:99:8) at Watcher.emit (events.js:189:13) at /app/node_modules/watchpack/lib/DirectoryWatcher.js:109:7 at Array.forEach (<anonymous>) at DirectoryWatcher.setFileTime (/app/node_modules/watchpack/lib/DirectoryWatcher.js:108:41) at DirectoryWatcher.onChange (/app/node_modules/watchpack/lib/DirectoryWatcher.js:264:7) at FSWatcher.emit (events.js:189:13) at FSWatcher.<anonymous> (/app/node_modules/watchpack/node_modules/chokidar/index.js:199:15) at /app/node_modules/watchpack/node_modules/chokidar/index.js:238:7 at FSReqWrap.oncomplete (fs.js:155:5) ``` As suggested in shellscape#113 (comment) I've wrapped `send` so the error should not come back anymore.
8 tasks
niieani
added a commit
to niieani/webpack-plugin-serve
that referenced
this pull request
May 1, 2019
Follow up to shellscape#113. Even with the above fix, I encountered a similar issue, this time in the `invalid` handler: ``` uncaughtException Error: WebSocket is not open: readyState 2 (CLOSING) at WebSocket.send (/app/node_modules/webpack-plugin-serve/node_modules/ws/lib/websocket.js:322:19) at WebpackPluginServe.socket.invalid (/app/node_modules/webpack-plugin-serve/lib/routes.js:83:16) at WebpackPluginServe.emit (events.js:189:13) at invalid.tap (/app/node_modules/webpack-plugin-serve/lib/index.js:155:41) at SyncHook.eval (eval at create (/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1) at Watchpack.watcher.compiler.watchFileSystem.watch (/app/node_modules/webpack/lib/Watching.js:139:33) at Object.onceWrapper (events.js:277:13) at Watchpack.emit (events.js:189:13) at Watchpack._onChange (/app/node_modules/watchpack/lib/watchpack.js:118:7) at Watchpack.<anonymous> (/app/node_modules/watchpack/lib/watchpack.js:99:8) at Watcher.emit (events.js:189:13) at /app/node_modules/watchpack/lib/DirectoryWatcher.js:109:7 at Array.forEach (<anonymous>) at DirectoryWatcher.setFileTime (/app/node_modules/watchpack/lib/DirectoryWatcher.js:108:41) at DirectoryWatcher.onChange (/app/node_modules/watchpack/lib/DirectoryWatcher.js:264:7) at FSWatcher.emit (events.js:189:13) at FSWatcher.<anonymous> (/app/node_modules/watchpack/node_modules/chokidar/index.js:199:15) at /app/node_modules/watchpack/node_modules/chokidar/index.js:238:7 at FSReqWrap.oncomplete (fs.js:155:5) ``` As suggested in shellscape#113 (comment) I've wrapped `send` so the error should not come back anymore.
shellscape
pushed a commit
that referenced
this pull request
May 1, 2019
Follow up to #113. Even with the above fix, I encountered a similar issue, this time in the `invalid` handler: ``` uncaughtException Error: WebSocket is not open: readyState 2 (CLOSING) at WebSocket.send (/app/node_modules/webpack-plugin-serve/node_modules/ws/lib/websocket.js:322:19) at WebpackPluginServe.socket.invalid (/app/node_modules/webpack-plugin-serve/lib/routes.js:83:16) at WebpackPluginServe.emit (events.js:189:13) at invalid.tap (/app/node_modules/webpack-plugin-serve/lib/index.js:155:41) at SyncHook.eval (eval at create (/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1) at Watchpack.watcher.compiler.watchFileSystem.watch (/app/node_modules/webpack/lib/Watching.js:139:33) at Object.onceWrapper (events.js:277:13) at Watchpack.emit (events.js:189:13) at Watchpack._onChange (/app/node_modules/watchpack/lib/watchpack.js:118:7) at Watchpack.<anonymous> (/app/node_modules/watchpack/lib/watchpack.js:99:8) at Watcher.emit (events.js:189:13) at /app/node_modules/watchpack/lib/DirectoryWatcher.js:109:7 at Array.forEach (<anonymous>) at DirectoryWatcher.setFileTime (/app/node_modules/watchpack/lib/DirectoryWatcher.js:108:41) at DirectoryWatcher.onChange (/app/node_modules/watchpack/lib/DirectoryWatcher.js:264:7) at FSWatcher.emit (events.js:189:13) at FSWatcher.<anonymous> (/app/node_modules/watchpack/node_modules/chokidar/index.js:199:15) at /app/node_modules/watchpack/node_modules/chokidar/index.js:238:7 at FSReqWrap.oncomplete (fs.js:155:5) ``` As suggested in #113 (comment) I've wrapped `send` so the error should not come back anymore.
smashercosmo
pushed a commit
to smashercosmo/webpack-plugin-serve
that referenced
this pull request
Jul 23, 2019
smashercosmo
pushed a commit
to smashercosmo/webpack-plugin-serve
that referenced
this pull request
Jul 23, 2019
Follow up to shellscape#113. Even with the above fix, I encountered a similar issue, this time in the `invalid` handler: ``` uncaughtException Error: WebSocket is not open: readyState 2 (CLOSING) at WebSocket.send (/app/node_modules/webpack-plugin-serve/node_modules/ws/lib/websocket.js:322:19) at WebpackPluginServe.socket.invalid (/app/node_modules/webpack-plugin-serve/lib/routes.js:83:16) at WebpackPluginServe.emit (events.js:189:13) at invalid.tap (/app/node_modules/webpack-plugin-serve/lib/index.js:155:41) at SyncHook.eval (eval at create (/app/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1) at Watchpack.watcher.compiler.watchFileSystem.watch (/app/node_modules/webpack/lib/Watching.js:139:33) at Object.onceWrapper (events.js:277:13) at Watchpack.emit (events.js:189:13) at Watchpack._onChange (/app/node_modules/watchpack/lib/watchpack.js:118:7) at Watchpack.<anonymous> (/app/node_modules/watchpack/lib/watchpack.js:99:8) at Watcher.emit (events.js:189:13) at /app/node_modules/watchpack/lib/DirectoryWatcher.js:109:7 at Array.forEach (<anonymous>) at DirectoryWatcher.setFileTime (/app/node_modules/watchpack/lib/DirectoryWatcher.js:108:41) at DirectoryWatcher.onChange (/app/node_modules/watchpack/lib/DirectoryWatcher.js:264:7) at FSWatcher.emit (events.js:189:13) at FSWatcher.<anonymous> (/app/node_modules/watchpack/node_modules/chokidar/index.js:199:15) at /app/node_modules/watchpack/node_modules/chokidar/index.js:238:7 at FSReqWrap.oncomplete (fs.js:155:5) ``` As suggested in shellscape#113 (comment) I've wrapped `send` so the error should not come back anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains:
Breaking Changes?
If yes, please describe the breakage.
Please Describe Your Changes
Fixes a case in which we tried to send data through a socket that isn't connected due to the client being in the middle of a page reload (and thus closing the connection). This exception killed the whole webpack process.
Example stacktrace: