Skip to content

[P3] Preserve optional process.off compatibility in getProcessDeps #634

Description

@Keegs12

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions