Make flipper-server-client gracefully handle malformed messages
Summary: FlipperServerClient can use any socket to transfer the data. Since we do not control the socket, we cannot guarantee what comes out of it (hello, Jest E2E tunnel!). We need to handle unexpected messages gracefully. Reviewed By: passy Differential Revision: D40891384 fbshipit-source-id: 6f873037aa49bac3fc4c09fa49483cdec537ae40
This commit is contained in:
committed by
Facebook GitHub Bot
parent
60a439ef7b
commit
2a108854d2
@@ -84,6 +84,7 @@ export function createFlipperServerWithSocket(
|
||||
});
|
||||
|
||||
socket.addEventListener('message', ({data}) => {
|
||||
try {
|
||||
const {event, payload} = JSON.parse(
|
||||
data.toString(),
|
||||
) as ServerWebSocketMessage;
|
||||
@@ -129,6 +130,12 @@ export function createFlipperServerWithSocket(
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(
|
||||
'flipper-server: failed to process message',
|
||||
data.toString(),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const commandOrOptionsIsOptions = (
|
||||
|
||||
Reference in New Issue
Block a user