Skip to content

Add cancellable operations and Abort support#6

Open
javisperez wants to merge 2 commits intomainfrom
support-abort-controllers
Open

Add cancellable operations and Abort support#6
javisperez wants to merge 2 commits intomainfrom
support-abort-controllers

Conversation

@javisperez
Copy link
Copy Markdown
Collaborator

  • Introduce cancellable CLI operations and AbortSignal handling across the library.
  • Added CancellablePromise type and cancellable(fn) helper in core/exec
  • Extended runCommand to accept an AbortSignal (kills child with SIGTERM and rejects with AbortError), and exported CancellablePromise from the public API.
  • Updated pack, pull and unpack to return CancellablePromise and wire cancellation into runCommand.
  • Updated tests to cover AbortSignal behaviour and cancel() semantics, and adjusted existing tests to expect the signal argument.
  • Bumped package version to 0.1.0.

Introduce cancellable CLI operations and AbortSignal handling across the library. Added CancellablePromise type and cancellable(fn) helper in core/exec, extended runCommand to accept an AbortSignal (kills child with SIGTERM and rejects with AbortError), and exported CancellablePromise from the public API. Updated pack, pull and unpack to return CancellablePromise and wire cancellation into runCommand. Updated tests to cover AbortSignal behaviour and cancel() semantics, and adjusted existing tests to expect the signal argument. Bumped package version to 0.1.0.

Signed-off-by: Javis Pérez <javis@jozu.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class cancellation support for long-running KitOps CLI operations by introducing a CancellablePromise abstraction, wiring AbortSignal through runCommand, and updating key command wrappers/tests accordingly.

Changes:

  • Added CancellablePromise<T> (public type) and cancellable(fn) helper to expose .cancel() on async operations.
  • Extended runCommand to accept an AbortSignal, terminate the spawned child on abort, and reject accordingly.
  • Updated pack, pull, and unpack to return CancellablePromise<void> and adjusted/added tests; bumped package version to 0.1.0.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/kitops.ts Introduces the public CancellablePromise<T> type and documentation.
src/index.ts Re-exports CancellablePromise from the public API surface.
src/core/exec.ts Adds AbortSignal support to runCommand and implements cancellable() helper.
src/core/tests/exec.spec.ts Adds tests covering abort semantics and cancellable() behavior.
src/commands/pack.ts Returns CancellablePromise<void> and wires internal cancellation into runCommand.
src/commands/pull.ts Returns CancellablePromise<void> and wires internal cancellation into runCommand.
src/commands/unpack.ts Returns CancellablePromise<void> and wires internal cancellation into runCommand.
src/commands/tests/pack.spec.ts Updates mocks/expectations for the new AbortSignal argument and .cancel().
src/commands/tests/pull.spec.ts Updates mocks/expectations for the new AbortSignal argument and .cancel().
src/commands/tests/unpack.spec.ts Updates mocks/expectations for the new AbortSignal argument and .cancel().
package.json Version bump to 0.1.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/exec.ts
Comment thread src/core/exec.ts
Comment thread src/core/exec.ts Outdated
Signed-off-by: Javis Pérez <javis@jozu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants