From 0df5bcee459d881c8e0e609430fca6c7b91c4973 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 24 Nov 2021 17:41:51 -0500 Subject: [PATCH] Fix broken feature layout due to async race condition on getRpcDriver --- packages/core/rpc/RpcManager.ts | 17 +++++------------ packages/core/rpc/WebWorkerRpcDriver.ts | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/core/rpc/RpcManager.ts b/packages/core/rpc/RpcManager.ts index e1e34d05bd..78d1bb045d 100644 --- a/packages/core/rpc/RpcManager.ts +++ b/packages/core/rpc/RpcManager.ts @@ -5,7 +5,6 @@ import rpcConfigSchema from './configSchema' import WebWorkerRpcDriver from './WebWorkerRpcDriver' import MainThreadRpcDriver from './MainThreadRpcDriver' import { AnyConfigurationModel } from '../configuration/configurationSchema' -import { isElectron } from '../util' type DriverClass = WebWorkerRpcDriver | MainThreadRpcDriver type BackendConfigurations = { @@ -48,9 +47,7 @@ export default class RpcManager { this.driverObjects = new Map() } - async getDriver( - backendName: keyof typeof DriverClasses, - ): Promise { + getDriver(backendName: keyof typeof DriverClasses) { const driver = this.driverObjects.get(backendName) if (driver) { return driver @@ -61,19 +58,15 @@ export default class RpcManager { if (!DriverClassImpl) { throw new Error(`requested RPC driver "${backendName}" is not installed`) - } else if (!backendConfiguration) { - throw new Error(`requested RPC driver "${backendName}" is missing config`) } - let userDataDirectory: string | undefined = undefined - if (isElectron) { - // eslint-disable-next-line import/no-extraneous-dependencies - const { ipcRenderer }: typeof import('electron') = require('electron') - userDataDirectory = await ipcRenderer.invoke('userData') + + if (!backendConfiguration) { + throw new Error(`requested RPC driver "${backendName}" is missing config`) } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const newDriver = new DriverClassImpl(backendConfiguration as any, { plugins: this.pluginManager.runtimePluginDefinitions, - userData: userDataDirectory, }) this.driverObjects.set(backendName, newDriver) return newDriver diff --git a/packages/core/rpc/WebWorkerRpcDriver.ts b/packages/core/rpc/WebWorkerRpcDriver.ts index 75816b2319..35876fefbb 100644 --- a/packages/core/rpc/WebWorkerRpcDriver.ts +++ b/packages/core/rpc/WebWorkerRpcDriver.ts @@ -48,11 +48,11 @@ export default class WebWorkerRpcDriver extends BaseRpcDriver { WorkerClass: WebpackWorker - workerBootConfiguration: { plugins: PluginDefinition[]; userData?: string } + workerBootConfiguration: { plugins: PluginDefinition[] } constructor( args: WebWorkerRpcDriverConstructorArgs, - workerBootConfiguration: { plugins: PluginDefinition[]; userData?: string }, + workerBootConfiguration: { plugins: PluginDefinition[] }, ) { super(args) this.WorkerClass = args.WorkerClass