Handle disconnection events whilst executing requests
Summary: If there's a device client disconnect during request execution, no response is ever given back to the client (flipperd). This change effectively subscribes to client disconnect events and notifies flipperd of any disconnection during request processing. Reviewed By: passy Differential Revision: D37787986 fbshipit-source-id: 31737a50b83b0cbe4141ce814064aebef7e09bfc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
01fc74d4f1
commit
c01df31459
@@ -378,7 +378,23 @@ export class FlipperServerCompanion {
|
||||
);
|
||||
}
|
||||
|
||||
return pluginInstance.companionApi[api](...(params ?? []));
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const closeHandle = () => {
|
||||
reject(new Error('Client disconnected whilst executing request'));
|
||||
};
|
||||
client.once('close', closeHandle);
|
||||
|
||||
try {
|
||||
const response = await pluginInstance.companionApi[api](
|
||||
...(params ?? []),
|
||||
);
|
||||
resolve(response);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
} finally {
|
||||
client.off('close', closeHandle);
|
||||
}
|
||||
});
|
||||
},
|
||||
'companion-plugin-subscribe': async (clientId, pluginId, api) => {
|
||||
const client = this.clients.get(clientId);
|
||||
|
||||
Reference in New Issue
Block a user