You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
The response passed to the PageIterator should be intact after iteration.
Change the Array.shift method to use Array.slice and keep a cursor index.
Actual behavior:
The response passed to the PageIterator is empty after the iteration.
As you can see the fakeGraphApiResponse.value have been mutate and is now empty.
I would have expect that the fakeGraphApiResponse would have been left has it was.
The output should have been:
I apologize if this is not the right place or format for this. I haven't commented before.
The callback for the PageIterator callback is not firing for me for pages after the first. I believe this may be related to the change here.
iterationHelper() checks that the cursor is lower than the collection length and iterates this.cursor until that value exceeds the collection length. It is initialized to 0 in the constructor.
This works for the first page. However, fetchAndUpdateNextPageData() does not reset the cursor. That means that for each subsequent page, the cursor is already at the collection length, effectively skipping the callback while continuing to iterate through the pages.
I believe adding this.cursor = 0; to the end of the fetchAndUpdateNextPageData() function resolves the problem for me
Activity
nikithauc commentedon Sep 14, 2022
Olivier Cuypers (@OlivierCuyp) Thank you for bringing this up.
Can you please provide the steps to reproduce the issue, that is, the use case which is throwing the unexpected behaviour
OlivierCuyp commentedon Sep 14, 2022
Nikitha Chettiar (@nikithauc) I think, the fix would have been written faster than the example, but here it is:
test.ts
Running it gives:
❯ npx ts-node ./test.ts { value: [] }As you can see the
fakeGraphApiResponse.valuehave been mutate and is now empty.I would have expect that the
fakeGraphApiResponsewould have been left has it was.The output should have been:
❯ npx ts-node ./test.ts { value: [{ foo: 'bar' }] }OlivierCuyp commentedon Sep 14, 2022
Nikitha Chettiar (@nikithauc) since it was a quick fix, I made a PR.
nikithauc commentedon Nov 3, 2022
Fix released in v3.0.3
NickFenzan commentedon Nov 14, 2022
I apologize if this is not the right place or format for this. I haven't commented before.
The callback for the PageIterator callback is not firing for me for pages after the first. I believe this may be related to the change here.
iterationHelper() checks that the cursor is lower than the collection length and iterates this.cursor until that value exceeds the collection length. It is initialized to 0 in the constructor.
This works for the first page. However, fetchAndUpdateNextPageData() does not reset the cursor. That means that for each subsequent page, the cursor is already at the collection length, effectively skipping the callback while continuing to iterate through the pages.
I believe adding this.cursor = 0; to the end of the fetchAndUpdateNextPageData() function resolves the problem for me
sebastienlevert commentedon Nov 14, 2022
This has been fixed in 3.0.4 and merged here : #1046
Can you update to the latest version and test if this solves the issue? Thanks!
NickFenzan commentedon Nov 15, 2022
Oops, thought I had the most recent version. Yes, that works. Thanks!