From 5a1c3d024bd2b4ddcd1014564899d6e3d89c5e7e Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 2 Apr 2026 14:57:53 -0700 Subject: [PATCH] plugin: add type assertions for strictNullChecks in runtime workers Fix strictNullChecks: - child-process-worker.ts: add definite assignment for childProcess - custom-worker.ts: add assertions for pluginDevice and options - node-fork-worker.ts: add catch block type annotation - node-thread-worker.ts: add catch block type annotation - python-worker.ts: add assertions for worker properties --- server/src/plugin/runtime/child-process-worker.ts | 2 +- server/src/plugin/runtime/custom-worker.ts | 8 ++++---- server/src/plugin/runtime/node-fork-worker.ts | 2 +- server/src/plugin/runtime/node-thread-worker.ts | 2 +- server/src/plugin/runtime/python-worker.ts | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/plugin/runtime/child-process-worker.ts b/server/src/plugin/runtime/child-process-worker.ts index fbd6f71b3..7f0df2ceb 100644 --- a/server/src/plugin/runtime/child-process-worker.ts +++ b/server/src/plugin/runtime/child-process-worker.ts @@ -6,7 +6,7 @@ import { RuntimeWorker, RuntimeWorkerOptions } from "./runtime-worker"; export abstract class ChildProcessWorker extends EventEmitter implements RuntimeWorker { public pluginId: string; protected worker: child_process.ChildProcess | undefined; - killPromise: Promise; + killPromise!: Promise; get childProcess() { return this.worker; diff --git a/server/src/plugin/runtime/custom-worker.ts b/server/src/plugin/runtime/custom-worker.ts index f816785d0..8b33d5b54 100644 --- a/server/src/plugin/runtime/custom-worker.ts +++ b/server/src/plugin/runtime/custom-worker.ts @@ -8,13 +8,13 @@ import { ChildProcessWorker } from "./child-process-worker"; import { RuntimeWorkerOptions } from "./runtime-worker"; export class CustomRuntimeWorker extends ChildProcessWorker { - serializer: ReturnType; - fork: boolean; + serializer!: ReturnType; + fork!: boolean; constructor(options: RuntimeWorkerOptions, runtime: ScryptedRuntime) { super(options); - const pluginDevice = runtime.findPluginDevice(this.pluginId); + const pluginDevice = runtime.findPluginDevice(this.pluginId)!; const scryptedRuntimeArguments: ScryptedRuntimeArguments = pluginDevice.state.scryptedRuntimeArguments?.value; if (!scryptedRuntimeArguments) throw new Error('custom runtime requires scryptedRuntimeArguments'); @@ -75,7 +75,7 @@ export class CustomRuntimeWorker extends ChildProcessWorker { this.serializer.sendMessage(message, reject, serializationContext); } catch (e) { - reject?.(e); + reject?.(e as Error); } } } diff --git a/server/src/plugin/runtime/node-fork-worker.ts b/server/src/plugin/runtime/node-fork-worker.ts index 433246cb9..82b1f95fe 100644 --- a/server/src/plugin/runtime/node-fork-worker.ts +++ b/server/src/plugin/runtime/node-fork-worker.ts @@ -105,7 +105,7 @@ export class NodeForkWorker extends ChildProcessWorker { }); } catch (e) { - reject?.(e); + reject?.(e as Error); } } diff --git a/server/src/plugin/runtime/node-thread-worker.ts b/server/src/plugin/runtime/node-thread-worker.ts index 17a0e32a8..f5a54e309 100644 --- a/server/src/plugin/runtime/node-thread-worker.ts +++ b/server/src/plugin/runtime/node-thread-worker.ts @@ -129,7 +129,7 @@ export class NodeThreadWorker extends EventEmitter implements RuntimeWorker { port.postMessage(postMessage, transferList); } catch (e) { - reject?.(e); + reject?.(e as Error); } } diff --git a/server/src/plugin/runtime/python-worker.ts b/server/src/plugin/runtime/python-worker.ts index f0df7212a..96319df5e 100644 --- a/server/src/plugin/runtime/python-worker.ts +++ b/server/src/plugin/runtime/python-worker.ts @@ -26,7 +26,7 @@ export class PythonRuntimeWorker extends ChildProcessWorker { } } - serializer: ReturnType; + serializer!: ReturnType; peerin: Writable; peerout: Readable; _stdout = new PassThrough(); @@ -200,7 +200,7 @@ export class PythonRuntimeWorker extends ChildProcessWorker { this.serializer.sendMessage(message, reject, serializationContext); } catch (e) { - reject?.(e); + reject?.(e as Error); } } }