Skip to content

docs(postguard-js): document retry config, onRetry hook, resumable downloads, UploadSessionExpiredError #68

@dobby-coder

Description

@dobby-coder

The postguard-js SDK shipped two large user-facing features in v1.4–1.6 that have no coverage in the SDK reference pages.

What needs documenting

1. PostGuardConfig.retry and the onRetry hook (postguard-js#47)

Cryptify chunk PUTs and downloads now retry transient failures automatically. The retry budget, delays, and per-phase timeouts are configurable. Add a "Retries and timeouts" subsection to docs/sdk/js-encryption.md (and link from docs/sdk/js-decryption.md for the download side) covering:

  • retry: RetryOptions on PostGuardConfig — defaults: 5 attempts, 500 ms initial delay, 30 s cap, 2× multiplier, full jitter
  • Per-phase timeouts: chunkTimeoutMs (60 s default), finalizeTimeoutMs (120 s default), downloadTimeoutMs (off by default — bounded by retry budget)
  • Retry classification: 5xx / network errors / internal-timeout AbortError → retry; 4xx / UploadSessionExpiredError / caller abort → fail
  • onRetry: (event: RetryEvent) => void hook for surfacing "retrying… (attempt N of M)" in the UI
  • initUpload and finalizeUpload are deliberately not retried

Source PR: encryption4all/postguard-js#47

2. Resumable downloads via Range header (postguard-js#52)

downloadFileWithRetry now resumes mid-stream failures using a Range header. Briefly document the new behaviour in docs/sdk/js-decryption.md:

  • Mid-stream errors trigger a resume from the current offset
  • Resume requires 206 Partial Content with a matching Content-Range; a 200 reply on resume is treated as fail-not-retry (silent-rewind protection)
  • A flapping connection that delivers some bytes per attempt still exhausts the shared retry budget — does not loop forever
  • The function now returns the ReadableStream synchronously (stream-level errors surface on the consumer's first read(), not via a function-level rejection). This is a behaviour change for callers that did await downloadFileWithRetry(...).

Source PR: encryption4all/postguard-js#52

3. New UploadSessionExpiredError (postguard-js#47)

Add a row to docs/sdk/js-errors.md. Subclass of NetworkError, parsed from cryptify's structured 404 body (upload_session_not_found). Distinct from NetworkError so retry policies short-circuit. Surfaced from both chunk and finalize paths.

Verification

  • Confirm symbols exist on main of encryption4all/postguard-js (don't trust the PR description alone — verify against current source).
  • Pin source links to a full commit hash. curl -sI each link before merging.
  • npm run docs:build must succeed.

Cross-link

The cryptify-side counterpart docs are tracked in a separate issue on this repo; the SDK retry contract relies on that wire behaviour.

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