Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: worker not disposed (#3086)
Wenzhao Hu3da4e67b3d6b
diff --git a/packages/rpc/src/plugin.ts b/packages/rpc/src/plugin.tsindex 6b8535a70e..7e32178ed2 100644--- a/packages/rpc/src/plugin.ts+++ b/packages/rpc/src/plugin.ts@@ -42,6 +42,8 @@ export interface IUniverRPCMainThreadConfig {export class UniverRPCMainThreadPlugin extends Plugin {static override pluginName = 'UNIVER_RPC_MAIN_THREAD_PLUGIN';+ private _internalWorker: Worker | null = null;+constructor(private readonly _config: IUniverRPCMainThreadConfig,@Inject(Injector) protected readonly _injector: Injector@@ -49,9 +51,20 @@ export class UniverRPCMainThreadPlugin extends Plugin {super();}+ override dispose(): void {+ super.dispose();++ if (this._internalWorker) {+ this._internalWorker.terminate();+ this._internalWorker = null;+ }+ }+override onStarting(): void {const { workerURL } = this._config;const worker = workerURL instanceof Worker ? workerURL : new Worker(workerURL);+ this._internalWorker = workerURL instanceof Worker ? null : worker;+const messageProtocol = createWebWorkerMessagePortOnMain(worker);const dependencies: Dependency[] = [[