diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index b97c00e2a..3263fa692 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -78,17 +78,26 @@ export function plugin(client: PluginClient) { async function processMetadata( incomingMetadata: Record, ) { - const mappedMeta = await Promise.all( - Object.values(incomingMetadata).map((metadata) => - streamInterceptor.transformMetadata(metadata), - ), - ); + try { + const mappedMeta = await Promise.all( + Object.values(incomingMetadata).map((metadata) => + streamInterceptor.transformMetadata(metadata), + ), + ); - metadata.update((draft) => { - for (const metadata of mappedMeta) { - draft.set(metadata.id, metadata); + metadata.update((draft) => { + for (const metadata of mappedMeta) { + draft.set(metadata.id, metadata); + } + }); + return true; + } catch (error) { + for (const metadata of Object.values(incomingMetadata)) { + pendingData.metadata[metadata.id] = metadata; } - }); + handleStreamError('Metadata', error); + return false; + } } //this holds pending any pending data that needs to be applied in the event of a stream interceptor error @@ -100,10 +109,17 @@ export function plugin(client: PluginClient) { const retryCallback = async () => { uiState.streamState.set({state: 'RetryingAfterError'}); - await processMetadata(pendingData.metadata); - if (pendingData.frame != null) { - await processSubtreeUpdate(pendingData.frame); + if (!(await processMetadata(pendingData.metadata))) { + //back into error state, dont proceed + return; } + if (pendingData.frame != null) { + if (!(await processSubtreeUpdate(pendingData.frame))) { + //back into error state, dont proceed + return; + } + } + uiState.streamState.set({state: 'Ok'}); pendingData.frame = null; pendingData.metadata = {}; @@ -129,14 +145,7 @@ export function plugin(client: PluginClient) { return; } - try { - await processMetadata(event.attributeMetadata); - } catch (error) { - for (const metadata of Object.values(event.attributeMetadata)) { - pendingData.metadata[metadata.id] = metadata; - } - handleStreamError('Metadata', error); - } + await processMetadata(event.attributeMetadata); }); const perfEvents = createDataSource([], { @@ -239,9 +248,11 @@ export function plugin(client: PluginClient) { }); applyFrameworkEvents(subtreeUpdate); + return true; } catch (error) { pendingData.frame = subtreeUpdate; handleStreamError('Frame', error); + return false; } }; diff --git a/desktop/plugins/public/ui-debugger/package.json b/desktop/plugins/public/ui-debugger/package.json index 6505e1e99..710946226 100644 --- a/desktop/plugins/public/ui-debugger/package.json +++ b/desktop/plugins/public/ui-debugger/package.json @@ -16,7 +16,9 @@ "lodash": "^4.17.21", "react-color": "^2.19.3", "react-hotkeys-hook": "^3.4.7", - "react-query": "^3.39.1" + "react-query": "^3.39.1", + "ts-retry-promise": "^0.7.0", + "memoize-weak": "^1.0.2" }, "bugs": { "url": "https://github.com/facebook/flipper/issues" diff --git a/desktop/plugins/public/yarn.lock b/desktop/plugins/public/yarn.lock index 5b2cdbce1..6b951c499 100644 --- a/desktop/plugins/public/yarn.lock +++ b/desktop/plugins/public/yarn.lock @@ -1449,6 +1449,11 @@ material-colors@^1.2.1: resolved "https://registry.yarnpkg.com/material-colors/-/material-colors-1.2.6.tgz#6d1958871126992ceecc72f4bcc4d8f010865f46" integrity sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg== +memoize-weak@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/memoize-weak/-/memoize-weak-1.0.2.tgz#d0015a4c7c6cff2263dbbb49db1dc206ebb94916" + integrity sha512-gj39xkrjEw7nCn4nJ1M5ms6+MyMlyiGmttzsqAUsAKn6bYKwuTHh/AO3cKPF8IBrTIYTxb0wWXFs3E//Y8VoWQ== + micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -2198,6 +2203,11 @@ traverse@0.4.x: resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.4.6.tgz#d04b2280e4c792a5815429ef7b8b60c64c9ccc34" integrity sha1-0EsigOTHkqWBVCnve4tgxkyczDQ= +ts-retry-promise@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/ts-retry-promise/-/ts-retry-promise-0.7.0.tgz#08f2dcbbf5d2981495841cb63389a268324e8147" + integrity sha512-x6yWZXC4BfXy4UyMweOFvbS1yJ/Y5biSz/mEPiILtJZLrqD3ZxIpzVOGGgifHHdaSe3WxzFRtsRbychI6zofOg== + unicode-substring@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unicode-substring/-/unicode-substring-1.0.0.tgz#659fb839078e7bee84b86c27210ac4db215bf885"