Cap the number of errors and warnings for bulk KV put#9775
Conversation
🦋 Changeset detectedLatest commit: 4af7085 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
These changes have been automatically backported to Wrangler v3 🎉 You can view the automatically updated PR at v3-maintenance...v3-backport-9775. Please check that PR for correctness, and make sure it's merged after this one. Thank you for helping us keep Wrangler v3 supported! |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
| errors.push(`The item at index ${i} is ${JSON.stringify(keyValue)}`); | ||
| if (!isKVKeyValue(keyValue) && !maxNumberOfErrorsReached) { | ||
| if (errors.length === BATCH_MAX_ERRORS_WARNINGS) { | ||
| maxNumberOfErrorsReached = true; |
There was a problem hiding this comment.
instead of using this maxNumberOfErrorsReached flag, have you considered just breaking and exiting the loop? I feel like it might make sense to just quite after the few initial errors? is there any benefit in keeping looping through all the remaining entries?
There was a problem hiding this comment.
That's true, we could break if both maxNumberOfErrorsReached and maxNumberOfWarningsReached are reached. But it's probably not worth adding more code to optimize an error case?
a24e020 to
d47cbd9
Compare
Co-authored-by: Dario Piotrowicz <dario@cloudflare.com>
Fixes #9498
Queueing a lot of errors/warnings can fill up all the memory and slow down the process as described in the linked issue.