Draft: blocked on the core release. On Deno and Bun this test fails against the pinned @green-tea/core@26.9.0-beta.2, on purpose. Merge it together with the core pin bump to the first release that carries core #116 (merged in core #117), and not before. Until then, red runtimes (deno) and runtimes (bun) checks are expected. They are the regression being caught, not a broken test.
What this changes
The default keyOf buckets callers by ctx.ip. Until core #116, serveDeno and serveBun left ctx.ip as '', so every caller on those runtimes landed in the one 'unknown' bucket, and the first client to reach max locked out everyone else. Node's listen() always filled it from the socket.
packages/rate-limit/test/peer-ip.test.ts drives the plugin's defaultkeyOf over a real socket, on whichever runtime runs it:
one dual-stack listener on ::, via serveDeno, serveBun, or app.listen() on Node
max: 1; client A connects over 127.0.0.1 and client B over ::1
A's second request must be 429, B's first must be 200, and the two ctx.ip values must be non-empty and different
Node is the control: it passes on any core. A host with no IPv6 loopback falls back to 127.0.0.1 and 127.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 no engines change. 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 ci from the lockfile: @green-tea/core@26.9.0-beta.2 from npmjs.org, and Deno resolves that same tree through nodeModulesDir: "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 fail
npm 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 workerd
Against a candidate core built from core develop at 4d1639f and swapped into node_modules/@green-tea/core locally:
npm test: 61 pass, 0 fail
npm run test:deno: 32 pass, 0 fail
npm run test:bun: 32 pass, 0 fail
Checklist
The base branch above is contrib
Commits are signed off (git commit -s)
lint, format:check, typecheck, complexity:check and deno publish --dry-run pass locally
New behaviour has a test
Core is still imported as import type only in src/. The test imports it as a value, as the other tests do
engines unchanged
Not a breaking change
npm audit --audit-level=moderate: 0 vulnerabilities. No open Dependabot alerts.
> **Draft: blocked on the core release.** On Deno and Bun this test fails against the pinned `@green-tea/core@26.9.0-beta.2`, on purpose. Merge it together with the core pin bump to the first release that carries core #116 (merged in core #117), and not before. Until then, red `runtimes (deno)` and `runtimes (bun)` checks are expected. They are the regression being caught, not a broken test.
## What this changes
The default `keyOf` buckets callers by `ctx.ip`. Until core #116, `serveDeno` and `serveBun` left `ctx.ip` as `''`, so every caller on those runtimes landed in the one `'unknown'` bucket, and the first client to reach `max` locked out everyone else. Node's `listen()` always filled it from the socket.
`packages/rate-limit/test/peer-ip.test.ts` drives the plugin's **default** `keyOf` over a real socket, on whichever runtime runs it:
- one dual-stack listener on `::`, via `serveDeno`, `serveBun`, or `app.listen()` on Node
- `max: 1`; client A connects over `127.0.0.1` and client B over `::1`
- A's second request must be 429, B's first must be 200, and the two `ctx.ip` values must be non-empty and different
Node is the control: it passes on any core. A host with no IPv6 loopback falls back to `127.0.0.1` and `127.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 no `engines` change. 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 ci` from the lockfile: `@green-tea/core@26.9.0-beta.2` from npmjs.org, and Deno resolves that same tree through `nodeModulesDir: "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):
- [x] `npm test` (Node): 61 pass, 0 fail
- [x] `npm run test:deno`: 31 pass, **1 fail** (`ctx.ip was empty for client A on this serving path: ""`)
- [x] `npm run test:bun`: 31 pass, **1 fail** (same assertion)
- [ ] `npm run test:edge`: rate-limit does not declare workerd
Against a candidate core built from core `develop` at `4d1639f` and swapped into `node_modules/@green-tea/core` locally:
- [x] `npm test`: 61 pass, 0 fail
- [x] `npm run test:deno`: 32 pass, 0 fail
- [x] `npm run test:bun`: 32 pass, 0 fail
## Checklist
- [x] The base branch above is `contrib`
- [x] Commits are signed off (`git commit -s`)
- [x] `lint`, `format:check`, `typecheck`, `complexity:check` and `deno publish --dry-run` pass locally
- [x] New behaviour has a test
- [x] Core is still imported as `import type` only in `src/`. The test imports it as a value, as the other tests do
- [x] `engines` unchanged
- [x] Not a breaking change
`npm audit --audit-level=moderate`: 0 vulnerabilities. No open Dependabot alerts.
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>
chrnx
marked the pull request as work in progress 2026-10-14 02:55:22 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.