Skip to content
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

fix: scan manager scan limit should reset each invocation #374

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/core/src/classes/manager/scan-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export class ScanManager {

const allPromisesResponse = await Promise.all(
parallelScanOptions.map(options =>
this.toLimited(this.scan<Entity>(options, metadataOptions))
this.toLimited(this._scan<Entity>(options, metadataOptions))
)
);

Expand Down Expand Up @@ -407,6 +407,28 @@ export class ScanManager {
items: Entity[] | undefined;
unknownItems: DocumentClientTypes.AttributeMap[] | undefined;
cursor: DocumentClientTypes.Key | undefined;
}> {
// start with 0
this.itemsFetchedSoFarTotalParallelCount = 0;
return this._scan(scanOptions, metadataOptions);
}

/**
* Internal implementation of scan.
* In all external use-cases scan should be used
* This implementation does not reset `itemsFetchedSoFarTotalParallelCount` as it is called from parallelScan
* @param {ScanManagerScanOptions} scanOptions
* @param {MetadataOptions} metadataOptions
* @returns {Promise<{items: Entity[] | undefined, unknownItems: DocumentClientTypes.AttributeMap[] | undefined, cursor: DocumentClientTypes.Key | undefined}>}
* @internal
*/
protected async _scan<Entity>(
scanOptions?: ScanManagerScanOptions,
metadataOptions?: MetadataOptions
): Promise<{
items: Entity[] | undefined;
unknownItems: DocumentClientTypes.AttributeMap[] | undefined;
cursor: DocumentClientTypes.Key | undefined;
}> {
const requestId = getUniqueRequestId(metadataOptions?.requestId);

Expand Down