Fix potential race conditions for starting/stopping server add-ons
Reviewed By: mweststrate Differential Revision: D34301593 fbshipit-source-id: 2950de8a8567318cd3e87eff176657df5ba8fd1b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bdbf79e3e1
commit
81d0057a8d
@@ -425,20 +425,23 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
'plugins-server-add-on-stop': async (pluginName, owner) =>
|
||||
this.pluginManager.stopServerAddOn(pluginName, owner),
|
||||
'plugins-server-add-on-request-response': async (payload) => {
|
||||
const serverAddOn = this.pluginManager.getServerAddOnForMessage(payload);
|
||||
if (serverAddOn) {
|
||||
return await serverAddOn.connection.sendExpectResponse(payload);
|
||||
try {
|
||||
const serverAddOn =
|
||||
this.pluginManager.getServerAddOnForMessage(payload);
|
||||
assertNotNull(serverAddOn);
|
||||
return await serverAddOn.sendExpectResponse(payload);
|
||||
} catch {
|
||||
return {
|
||||
length: 0,
|
||||
error: {
|
||||
message: `Server add-on for message '${JSON.stringify(
|
||||
payload,
|
||||
)} is no longer running.`,
|
||||
name: 'SERVER_ADDON_STOPPED',
|
||||
stacktrace: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
length: 0,
|
||||
error: {
|
||||
message: `Server add-on for message '${JSON.stringify(
|
||||
payload,
|
||||
)} is no longer running.`,
|
||||
name: 'SERVER_ADDON_STOPPED',
|
||||
stacktrace: '',
|
||||
},
|
||||
};
|
||||
},
|
||||
'doctor-get-healthchecks': getHealthChecks,
|
||||
'doctor-run-healthcheck': runHealthcheck,
|
||||
|
||||
Reference in New Issue
Block a user