From 5d14bb70c6693e6095b15d96e80f3070b8ee9a20 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 26 Jun 2023 08:58:06 +0100 Subject: [PATCH] Ensure builder websocket is only instantiated once --- packages/builder/src/builderStore/store/frontend.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index d0414b5733..8160939df9 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -117,10 +117,13 @@ export const getFrontendStore = () => { reset: () => { store.set({ ...INITIAL_FRONTEND_STATE }) websocket?.disconnect() + websocket = null }, initialise: async pkg => { const { layouts, screens, application, clientLibPath, hasLock } = pkg - websocket = createBuilderWebsocket(application.appId) + if (!websocket) { + websocket = createBuilderWebsocket(application.appId) + } await store.actions.components.refreshDefinitions(application.appId) // Reset store state