Found while auditing Stack #633 (#628–#633); this also matches the unresolved review thread on PR #633.
Problem
ProcessDeps.offSignal and ProcessLike.off are typed as optional, and ProcessPlatformAdapter.removeSignalHandlers() already uses optional chaining. However, getProcessDeps() now rejects the runtime unless processLike.off exists:
if (!processLike?.env || !processLike.on || !processLike.off || !processLike.exit || !cryptoLike?.randomUUID) {
throw new Error('Process runtime is not available');
}
That makes the optional contract unreachable for Node/Bun-compatible process shims or older runtimes that provide on but not off, and it turns what could be a cleanup limitation into a startup failure.
Relevant code:
pkgs/edge-worker/src/platform/processDeps.ts:28-41
pkgs/edge-worker/src/platform/ProcessPlatformAdapter.ts:151-160
Suggested fix
Remove !processLike.off from the required-runtime check and construct offSignal only when processLike.off is present. Add a unit test with a process-like object that has on but no off, verifying dependency creation and worker startup still work.
Found while auditing Stack #633 (#628–#633); this also matches the unresolved review thread on PR #633.
Problem
ProcessDeps.offSignalandProcessLike.offare typed as optional, andProcessPlatformAdapter.removeSignalHandlers()already uses optional chaining. However,getProcessDeps()now rejects the runtime unlessprocessLike.offexists:That makes the optional contract unreachable for Node/Bun-compatible process shims or older runtimes that provide
onbut notoff, and it turns what could be a cleanup limitation into a startup failure.Relevant code:
pkgs/edge-worker/src/platform/processDeps.ts:28-41pkgs/edge-worker/src/platform/ProcessPlatformAdapter.ts:151-160Suggested fix
Remove
!processLike.offfrom the required-runtime check and constructoffSignalonly whenprocessLike.offis present. Add a unit test with a process-like object that hasonbut nooff, verifying dependency creation and worker startup still work.