Make sure that plugins don't store events unbounded

Summary:
To avoid plugins to collect data forever and store it (if they are never opened), introduced a hard-coded default limit on how many events will be preserved.

A semantic change is that plugins have to be potentially resistant against missing events. So far, during testing, this didn't seem to cause any problems.

Reviewed By: jonathoma

Differential Revision: D19175912

fbshipit-source-id: 828be941e76b7356c9f5be7e5a49de9a7a31b0d2
This commit is contained in:
Michel Weststrate
2020-01-02 07:12:06 -08:00
committed by Facebook Github Bot
parent 8c8f360572
commit 0494a84d98
5 changed files with 78 additions and 12 deletions

View File

@@ -128,6 +128,7 @@ export function processMessageLater(
defaultPersistedState: any;
name: string;
persistedStateReducer: PersistedStateReducer | null;
maxQueueSize?: number;
},
message: {method: string; params?: any},
) {
@@ -149,7 +150,14 @@ export function processMessageLater(
} else {
// TODO: possible optimization: drop all messages for non-favorited plugins
// TODO: possible optimization: drop messages if queue is too large
store.dispatch(queueMessage(pluginKey, message.method, message.params));
store.dispatch(
queueMessage(
pluginKey,
message.method,
message.params,
plugin.maxQueueSize,
),
);
}
}