Random problem with listObjectsV2 today

The problem is that this code doesn’t work as expected. We haven’t changed anything in our code, it just stopped working properly today (around 2-3 hours ago)

async listAllKeysWithPrefix(prefix: string) {
        let allKeys: string[] = []
        let isTruncated: boolean | undefined = true
        let continuationToken: string | undefined

        while (isTruncated) {
            const params: {
                Bucket: string
                Prefix: string
                ContinuationToken?: string
            } = {
                Bucket: this.bucketName,
                Prefix: prefix,
            }

            if (continuationToken) {
                params.ContinuationToken = continuationToken
            }

            try {
                const data = await this.s3.listObjectsV2(params).promise()
                if (data.Contents) {
                    const contents = data.Contents.filter((obj) => obj?.Key)
                    allKeys = allKeys.concat(
                        contents.map((obj) => obj.Key as string),
                    )
                }

                isTruncated = data.IsTruncated
                continuationToken = data.NextContinuationToken
            } catch (err) {
                logger.error(err)
                break
            }
        }
        return allKeys
    }

allKeys do not actually show all keys. It is showing some but not everything. It works fine when region that is doing this request is central asia, but not when region is US Ohio

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.