Repository navigation
Conversation
…on every runtime The default keyOf buckets callers by ctx.ip. serveDeno and serveBun left ctx.ip empty until core #116 (merged in core #117), so every caller on those runtimes shared the 'unknown' bucket and the first one to reach max locked out everybody else. This drives the plugin's default keyOf over a real socket: one dual-stack listener, client A over 127.0.0.1 and client B over ::1, max: 1. A's second request must be 429 and B's first 200, with two distinct ctx.ip values. Node's listen() path runs the same test as the control and passes on any core; on Deno and Bun it passes only on a core that carries #116, and fails on 26.9.0-beta.2. Hosts without an IPv6 loopback fall back to 127.0.0.1 and 127.0.0.2, which only Linux routes. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Contributor
Author
|
Moved to the primary forge, where this repository's pull requests are reviewed. This mirror is synced from there. |
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.
What this changes
The default
keyOfbuckets callers byctx.ip. Until core #116,serveDenoandserveBunleftctx.ipas'', so every caller on those runtimes landed in the one'unknown'bucket, and the first client to reachmaxlocked out everyone else. Node'slisten()always filled it from the socket.packages/rate-limit/test/peer-ip.test.tsdrives the plugin's defaultkeyOfover a real socket, on whichever runtime runs it:::, viaserveDeno,serveBun, orapp.listen()on Nodemax: 1; client A connects over127.0.0.1and client B over::1ctx.ipvalues must be non-empty and differentNode is the control: it passes on any core. A host with no IPv6 loopback falls back to
127.0.0.1and127.0.0.2, which only Linux routes, and the test logs a diagnostic when it does.Test only. There is no plugin-contract change, no
src/change and noengineschange. Nothing in this PR bumps the core pin. That belongs to the release cut.Why a draft rather than a skip
CI installs core with
npm cifrom the lockfile:@green-tea/core@26.9.0-beta.2from npmjs.org, and Deno resolves that same tree throughnodeModulesDir: "manual". No mechanism points CI at an unreleased core, and the repo has no convention for tests that wait on one. Skipping on old core, or marking the test todo, would let it pass silently on exactly the core it exists to reject. So the test stays strict, and this PR waits for the pin.Which runtimes you ran
Against the pinned
26.9.0-beta.2(what CI will see):npm test(Node): 61 pass, 0 failnpm run test:deno: 31 pass, 1 fail (ctx.ip was empty for client A on this serving path: "")npm run test:bun: 31 pass, 1 fail (same assertion)npm run test:edge: rate-limit does not declare workerdAgainst a candidate core built from core
developat4d1639fand swapped intonode_modules/@green-tea/corelocally:npm test: 61 pass, 0 failnpm run test:deno: 32 pass, 0 failnpm run test:bun: 32 pass, 0 failChecklist
contribgit commit -s)lint,format:check,typecheck,complexity:checkanddeno publish --dry-runpass locallyimport typeonly insrc/. The test imports it as a value, as the other tests doenginesunchangednpm audit --audit-level=moderate: 0 vulnerabilities. No open Dependabot alerts.