Skip to content

fix: pass pagination_token from entriesResponse to the recursive call in bulk unpublish getSyncEntries #1973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,11 @@ async function getSyncEntries(
await bulkAction(stack, entriesResponse.items, bulkUnpublish, environment, locale, apiVersion, bulkPublishLimit, false);
}

if (entriesResponse.items.length === 0) {
if (!entriesResponse.pagination_token) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MetodiYanev I have reviewed your changes — it looks good overall. Just a suggestion to update the exit condition with the latest logic:
if (entriesResponse.items.length === 0 && !entriesResponse.pagination_token)
This ensures the sync process only stops when there are truly no more items and no further pages (pagination_token).
Earlier, checking only items.length === 0 could cause premature exit even when more data was available.

CC: @netrajpatel @aman19K @AniketDev7

if (!changedFlag) console.log('No Entries/Assets Found published on specified environment');
return resolve();
}

setTimeout(async () => {
await getSyncEntries(
stack,
Expand All @@ -244,9 +245,11 @@ async function getSyncEntries(
apiVersion,
bulkPublishLimit,
variantsFlag,
null,
entriesResponse.pagination_token,
);
}, 3000);

return resolve();
} catch (error) {
reject(error);
}
Expand Down