naystack - v1.9.9
    Preparing search index...

    Function pollUntilReady

    • Reads a job's state until it stops being pending.

      Resolves null when the first read returns nothing. That is "unknown", not "failed": some jobs are complete the moment they exist and never publish a readable status, so treating null as an error would reject work that already succeeded. A short pause before returning gives such a job a beat to settle.

      Parameters

      • read: () => Promise<T | null>

        null means no state was readable.

      • isPending: (state: T) => boolean

        true while the state means "still working".

      • __namedParameters: PollOptions = {}

      Returns Promise<T | null>

      The last state read, or null if the state was never readable.

      import { pollUntilReady } from "naystack/socials";

      const state = await pollUntilReady(
      () => getInstagramContainerStatus(token, containerID),
      (s) => s.status === "IN_PROGRESS",
      );