Repository navigation
Conversation
reeceyang
force-pushed
the
reece/component-init-prototype
branch
from
November 20, 2026 02:20
db98ff8 to
013eb2c
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reeceyang
force-pushed
the
reece/component-init-prototype
branch
from
November 20, 2026 20:09
013eb2c to
6e449ff
Compare
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves named rate limit definitions into the component's install args,
app.use(rateLimiter, { args: { limits } }). The init stores onelimitsdocument per name, upserted through thenameindex and compared before writing so an unchanged push writes nothing, and deletes names that are no longer passed. Keying by name keeps each check's read dependency on just its own definition, so a push that changes one limit doesn't conflict with checks on the others, and it exercises an index read on the first push, in the same transaction that creates the table (convex/convex#61446).rateLimit,checkRateLimit,creditRateLimit,getValueandenqueueUpdatesnow takeconfigas optional and read the stored definition by name when it's absent. Inline configs stay, since ad-hoc and dynamically named limits aren't per-installation config, and they still take precedence. Enqueued updates resolve their definition at enqueue time, so the worker is unchanged. The client still takes the samelimitsobject for name types and to pick the transactional or asynchronous path, but no longer sends it per call.When a later push changes a definition, future checks use it right away. Existing
rateLimitsstate documents are left alone, even if the kind changes: the next check reinterprets the stored value and timestamp under the new definition, clamped to the new capacity, so it can't grant more than one capacity's worth. A token bucket that becomes a fixed window takes its last update time as its window start, so an explicitstartisn't honored for keys that already have state until they're reset. Resetting on a kind change would mean deleting a document per key, which doesn't fit in the init. The init reads each stored definition twice (the upsert lookup and the scan for removed names), so about 50 named limits fit within the 100-document and 16 KiB limits. Larger sets aren't handled here.The convex-test preview moves time forward a millisecond per commit, so a few existing tests compare values with
toBeCloseToinstead of exact equality.Not meant to merge. Depends on convex/convex#62236, convex/convex#62237 and convex/convex-test#212.
🤖 Generated with Claude Code