Search endpoint not auto-streaming

Hi,

I am using the NodeJS client API, with the following code.

 client.tasks.search(organizationId, {'completed': false})
      .then((collection: any) => {
        collection.stream().on('data', task => {
          console.log(task);
          })
          .on('end', () => {
          });
      });

All other endpoints stream data all to the end, but this one only fetches 50 values, and then stops… Any idea why?

Also when fetching explicitely for 200 results, it gives 50 only.

 collection.fetch(200).then(tasks => {
            console.log(tasks);
          })

My bad, this is explained in the doc.

Search results are not stable; repeating the same query multiple times may return the data in a different order, even if the data do not change. Because of this, the traditional pagination available elsewhere in the Asana API is not available here. However, you can paginate manually by sorting the search results by their creation time and then modifying each subsequent query to exclude data you have already seen. Page sizes are limited to a maximum of 100 items, and can be specified by the limit query parameter.

However this is not 100 items but 50.

Hey @Bastien_Siebman, I’m happy to hear you got this figured out. I just tested it and was able to get 100 results from the search endpoint. Am I understanding correctly that you are only able to get 50?

Yes, but that is not very important for now, because I won’t be going this way because streaming does not work for the search endpoint.