Skip to content

Commit 159f8fb

Browse files
committed
chore(web): listen to socket error to avoid uncaught exceptions
1 parent a86ca31 commit 159f8fb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/compass-web/scripts/electron-proxy.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ proxyServer.on('upgrade', async (req, socket, head) => {
404404
? https.request
405405
: http.request;
406406

407+
socket.on('error', (err) => {
408+
logger.error(err);
409+
});
410+
407411
prepareSocket(socket, head);
408412

409413
let extraHeaders = {};
@@ -430,7 +434,6 @@ proxyServer.on('upgrade', async (req, socket, head) => {
430434
socket.write(createHeaderStringFromResponse(proxyRes));
431435
proxyRes.pipe(socket);
432436
});
433-
434437
proxyReq.on('upgrade', async (proxyRes, proxySocket, proxyHead) => {
435438
// Will not be piped, so we do this manually
436439
proxySocket.on('error', (err) => {
@@ -512,6 +515,14 @@ function cleanupAndExit() {
512515
});
513516
}
514517

518+
process.on('uncaughtExceptionMonitor', (err, origin) => {
519+
logger.error(
520+
'Uncaught exception (caused by "%s"): ',
521+
origin,
522+
err.stack ?? err
523+
);
524+
});
525+
515526
electronApp.whenReady().then(async () => {
516527
// Create an empty browser window so that webdriver session can be
517528
// immediately get attached to something without failing

0 commit comments

Comments
 (0)