Skip to content

streams over paginate loop over the same record over and over again #466

Open
@jessfraz

Description

@jessfraz

Describe the bug

  • create an invoice item
  • list pending invoice items
  • use the stream pagination
  • watch as it loops endlessly over the same record
    some sample code:
#[tracing::instrument(skip(self))]
    async fn list_pending_invoice_items(&self, customer_id: &str) -> Result<Vec<crate::payments::types::InvoiceItem>> {
        // List all the invoice items that are PENDING for the customer.
        let mut invoice_items: Vec<crate::payments::types::InvoiceItem> = Default::default();

        let params = stripe::ListInvoiceItems {
            customer: Some(stripe::CustomerId::from_str(customer_id)?),
            limit: Some(100),
            pending: Some(true),
            ..Default::default()
        };
        let list = stripe::InvoiceItem::list(&self.client, &params).await?.paginate(params);
        let mut stream = list.stream(&self.client);
        // For each invoice in the stream add it to our array.
        while let Some(Ok(next)) = stream.next().await {
            invoice_items.push(next.into());
        }

        Ok(invoice_items)
    }

To Reproduce

see above sorry!

Expected behavior

Previous we were on version 0.21 now on 0.26 we see this bug. Without the code changing it appeared. So i would expect the stream to stop after its gotten all the records

Code snippets

No response

OS

macos

Rust version

1.75.0

Library version

0.26.0

API version

whatever the default is for the library?

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions