nylas / nylas-nodejs

A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
MIT License
167 stars 117 forks source link

Duplicated events returned from events.list #491

Closed ksirrah13 closed 9 months ago

ksirrah13 commented 10 months ago

Describe the bug In the list of events returned when calling nylas.events.list() there are duplicated entries. We are using expand_recurring=true, but I suspect the issue will happen even without using this option. The duplicated events seems to always appear right at a 100th event boundary leading me to suspect that the cause of the issue is the chunking and concatenation which is occurring here: https://github.com/nylas/nylas-nodejs/blob/main/src/models/model-collection.ts#L163

In some cases it will be the 99th and others it might be the 399th but it is localized around the end of a 100 entry chunk. Since this model list behavior is also used for other models I suspect this is not just an issue with events.

To Reproduce Because this is occurring on our customer's specific calendars and events I can't share specific calendars ids that have this result. Also, I have noticed that it does not occur on every API call, possibly due to updates to that user's calendar since they are still active.

I would suspect that as long as there are 100 or more events returned, requiring the chunking and concatenation, this should be reproducible eventually on any list of events or results.

// config nylas with account credentials
Nylas.config({
  clientId: <cliend_id>,
  clientSecret: <client_secret>,
});
// auth with access token
const nylas = Nylas.with(<access_token>);
// call list events and ensure it returns more than 100 results
const result = await nylas.events.list({
      // we are calling it for specific calendars but I don't think this is required for reproduction
      calendar_id: nylasCalendarId,
      // not sure if these are required to cause the issue but this is what we are using
      expand_recurring: true, 
      show_cancelled: true,
    });

If unable to reproduce on your own test data feel free to reach out to me and I'll work on finding or creating some non customer data I can share with you.

Expected behavior The resulting list of events should not contain any duplicated event or duplicated event ids.

SDK Version: nylas@6.10.0

mrashed-dev commented 9 months ago

Hey @ksirrah13 thanks for opening this ticket. I have successfully reproduced this issue, however after much testing with the SDK code I realized that this is an API issue rather than an SDK issue. If you try the same call via cURL or Postman, you will see some duplicates. Especially I found if you set limit to 100, and trying two calls one with offset at 300 and the other at 400. In the offset=300 call you can try cross checking the last few IDs with the first few IDs on the offset=400 call and you will see duplicate IDs.

I am going to close this issue as the bug is not an SDK-specific issue, but I will open a ticket internally with the appropriate team to investigate this and fix it in a future update.

If you think this is incorrect please don't hesitate to ping me and reopen this ticket. Thanks for your patience!

ksirrah13 commented 9 months ago

Thanks @mrashed-dev for the response. Is there any ticket we can monitor for the progress and potential fix of this issue in the API?

mrashed-dev commented 9 months ago

@ksirrah13 Unfortunately we don't have any system to track internal dev tickets like this. However if you'd like, you can submit a ticket request via support@nylas.com and the support team can open a Zendesk ticket for you where the support team can update you on progress.