@@ -32,18 +32,16 @@ function notifyClients() {
32
32
wsClients = wsClients . filter ( x => ! x . closed && ! x . socket . destroyed )
33
33
var wsClientsLen = wsClients . length
34
34
dlog ( `Alive sockets number: ${ wsClientsLen } ` )
35
- for ( var i = 0 ; i < wsClientsLen ; ++ i ) {
36
- // in reverse order, the last pushed get notified earlier
37
- var client = wsClients [ wsClientsLen - i - 1 ]
38
- if ( ! client . closed ) {
39
- client . sendText (
40
- JSON . stringify (
35
+ var data = JSON . stringify (
41
36
{
42
37
LAST_SUCCESS_BUILD_STAMP : LAST_SUCCESS_BUILD_STAMP
43
38
}
44
39
)
45
-
46
- )
40
+ for ( var i = 0 ; i < wsClientsLen ; ++ i ) {
41
+ // in reverse order, the last pushed get notified earlier
42
+ var client = wsClients [ wsClientsLen - i - 1 ]
43
+ if ( ! client . closed ) {
44
+ client . sendText ( data )
47
45
}
48
46
}
49
47
}
@@ -55,6 +53,9 @@ function setUpWebSocket() {
55
53
. on ( 'upgrade' , function ( req , socket , upgradeHead ) {
56
54
dlog ( "connection opened" ) ;
57
55
var ws = new WebSocket ( req , socket , upgradeHead ) ;
56
+ socket . on ( "error" , function ( err ) {
57
+ dlog ( `Socket Error ${ err } ` )
58
+ } )
58
59
wsClients . push ( ws )
59
60
} )
60
61
. on ( 'error' , function ( err ) {
@@ -147,7 +148,10 @@ if (watch_mode) {
147
148
*/
148
149
var watchers = [ ] ;
149
150
150
-
151
+ function onUncaughtException ( err ) {
152
+ console . error ( "Uncaught Exception" , err )
153
+ process . exit ( 1 )
154
+ }
151
155
function onExit ( ) {
152
156
try {
153
157
fs . unlinkSync ( lockFileName )
@@ -180,7 +184,7 @@ if (watch_mode) {
180
184
process . on ( 'SIGUSR2' , onExit )
181
185
process . on ( 'SIGTERM' , onExit )
182
186
process . on ( 'SIGHUP' , onExit )
183
- process . on ( 'uncaughtException' , onExit )
187
+ process . on ( 'uncaughtException' , onUncaughtException )
184
188
process . stdin . on ( 'close' , onExit )
185
189
// close when stdin stops
186
190
if ( os . platform ( ) !== "win32" ) {
0 commit comments