Skip to content

Commit

Permalink
fix: do not terminate socket on handshake error, triggers an annoying…
Browse files Browse the repository at this point in the history
… reload on dev
  • Loading branch information
b-ma committed May 23, 2024
1 parent b2b25d5 commit 22f4dd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,12 @@ dependancies on both your server and clients.
msg = `[soundworks:Client] ${err.message}`;
break;
default:
msg = `Undefined error`;
msg = `[soundworks:Client] Undefined error: ${err.message}`;
break;
}

this.socket[kSocketTerminate]();
// These are development errors, we can just hang. If we terminate the
// socket, a reload is triggered by the launcher which is bad in terms of DX
reject(msg);
});

Expand All @@ -293,8 +294,8 @@ dependancies on both your server and clients.

this.socket.send(CLIENT_HANDSHAKE_REQUEST, payload);
});
} catch (err) {
throw new Error(err);
} catch (msg) {
throw new Error(msg);
}

// ------------------------------------------------------------
Expand Down
18 changes: 14 additions & 4 deletions src/server/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import http from 'node:http';
import https from 'node:https';
import path from 'node:path';
import os from 'node:os';
import { X509Certificate, createPrivateKey } from 'node:crypto';
import {
X509Certificate,
createPrivateKey,
} from 'node:crypto';

import { isPlainObject, idGenerator, getTime } from '@ircam/sc-utils';
import {
isPlainObject,
idGenerator,
getTime,
} from '@ircam/sc-utils';
import chalk from 'chalk';
import compression from 'compression';
import express from 'express';
Expand All @@ -18,7 +25,10 @@ import pem from 'pem';
import compile from 'template-literal';

import auditSchema from './audit-schema.js';
import { encryptData, decryptData } from './crypto.js';
import {
encryptData,
decryptData,
} from './crypto.js';
import Client from './Client.js';
import ContextManager from './ContextManager.js';
import PluginManager from './PluginManager.js';
Expand Down Expand Up @@ -678,7 +688,7 @@ Invalid certificate files, please check your:
// this.httpsInfos.isValid = false; // for testing
if (!this.httpsInfos.isValid) {
logger.error(chalk.red` -------------------------------------------`);
logger.error(chalk.red` > INVALID CERTIFICATE`);
logger.error(chalk.red` > INVALID CERTIFICATE `);
logger.error(chalk.red` i.e. you pretend to be safe but you are not`);
logger.error(chalk.red` -------------------------------------------`);
} else {
Expand Down

0 comments on commit 22f4dd3

Please sign in to comment.