mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 08:56:17 -04:00
SocketIORouter: Don't crash if message handler throws
This commit is contained in:
parent
320e5c1109
commit
9f9adb369b
2 changed files with 25 additions and 2 deletions
|
@ -460,7 +460,7 @@ describe(__filename, function () {
|
|||
await disconnected;
|
||||
});
|
||||
|
||||
it('handleMessage', async function () {
|
||||
it('handleMessage (success)', async function () {
|
||||
let serverSocket;
|
||||
const want = {
|
||||
component: this.test.fullTitle(),
|
||||
|
@ -480,5 +480,24 @@ describe(__filename, function () {
|
|||
socket.send(want);
|
||||
assert.deepEqual(await got, want);
|
||||
});
|
||||
|
||||
it('handleMessage (error)', async function () {
|
||||
let receive;
|
||||
const received = new Promise((resolve) => receive = resolve);
|
||||
socketIoRouter.addComponent(this.test.fullTitle(), new class extends Module {
|
||||
handleMessage(socket, message) {
|
||||
if (message.throw) throw new Error('injected');
|
||||
receive();
|
||||
}
|
||||
}());
|
||||
socket = await connect();
|
||||
const tx = (msg = {}) => {
|
||||
msg = Object.assign({component: this.test.fullTitle(), protocolVersion: 2}, msg);
|
||||
socket.send(msg);
|
||||
};
|
||||
tx({throw: true});
|
||||
tx();
|
||||
await received;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue