Recover from args argument being uniterable
Summary: Another kind of error that can easily be triggered during testing that will kill the server otherwise. Changelog: Make it possible to recover from malformed JSON in server requests Reviewed By: timur-valiev Differential Revision: D34932896 fbshipit-source-id: 7c6acfd53ffbd85a54a786d74c99bcccb64d85cb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9c5d1a32c5
commit
d40ff61870
@@ -65,6 +65,21 @@ export function startSocketServer(
|
||||
case 'exec': {
|
||||
const {id, command, args} = payload;
|
||||
|
||||
if (typeof args[Symbol.iterator] !== 'function') {
|
||||
console.warn(
|
||||
'flipperServer -> exec: args argument in payload is not iterable',
|
||||
);
|
||||
const responseError: ExecResponseErrorWebSocketMessage = {
|
||||
event: 'exec-response-error',
|
||||
payload: {
|
||||
id,
|
||||
data: 'Payload args argument is not an iterable.',
|
||||
},
|
||||
};
|
||||
client.send(JSON.stringify(responseError));
|
||||
return;
|
||||
}
|
||||
|
||||
flipperServer
|
||||
.exec(command, ...args)
|
||||
.then((result: any) => {
|
||||
|
||||
Reference in New Issue
Block a user