Skip to content

feat: cancelable operations + stable error codes #366

Description

@cursor

Motivation

Large archives can run for a long time with no way to abort. Competitors (react-native-nitro-unzip, react-native-unarchive) already expose cancellation. Error handling is also inconsistent across platforms (generic messages, historically null codes), which makes UI branching hard.

Proposal

cancel(): Promise<void>

Cancel the in-flight zip/unzip operation (best-effort). Reject the active promise with a stable CANCELLED code. Clean up partial output where practical.

Stable error codes

Reject with a consistent code string on both platforms, e.g.:

Code When
ERR_FILE_NOT_FOUND Source missing
ERR_INVALID_PATH Bad destination / empty path
ERR_WRONG_PASSWORD Password decrypt failed
ERR_CORRUPT_ARCHIVE Not a zip / truncated / bad CRC
ERR_UNSAFE_PATH Zip Slip / symlink escape
ERR_CANCELLED User cancelled
ERR_BUSY Operation rejected because another is running (if serialized)
ERR_ZIP / ERR_UNZIP Generic fallback

Acceptance criteria

  • cancel() stops in-flight zip and unzip on iOS and Android
  • Cancelled promise rejects with ERR_CANCELLED
  • Existing failure paths map to the table above (no null codes)
  • Documented in README + TypeScript types for known codes
  • Tests cover cancel mid-unzip and wrong-password mapping

Priority

P0

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