Skip to content

injectAndPoll function breaks polling on first 404 instead of waiting for receipt #59

@Frank-en-stein

Description

@Frank-en-stein

Summary

The injectAndPoll function in src/resources/operations.ts is intended to poll for a receipt until it becomes available or until a timeout is reached. However, the current implementation rejects and stops polling as soon as a 404 (Not Found) response is received from getReceipt. This prevents the function from waiting for the receipt as intended.

Expected Behavior

  • The function should continue polling on 404 responses, only stopping when a 200 response is received (receipt found) or the polling times out.
  • Only 404 errors should be ignored; any other HTTP errors should still cause the polling to stop and reject.

Actual Behavior

  • Polling stops immediately on the first 404 response, even if the receipt might become available later within the timeout window.

Steps to Reproduce

  1. Call injectAndPoll with an operation that takes time to produce a receipt.
  2. If getReceipt returns 404 initially, the function will immediately stop instead of polling until timeout.

Proposed Solution

  • Update the polling logic to catch 404 errors specifically and continue polling when they occur.
  • All other errors should still reject the polling.

Additional Requirements

  • Add mocked tests to ensure:
    • Polling continues through repeated 404s until timeout.
    • Polling resolves when a 200 is received.
    • Polling stops on any non-404 error.

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