1 Commits
Author SHA1 Message Date
chrnx 77d4f32eff fix(mesh): RPC frames wait for the send buffer too (CARD-26, #41)
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 20s
CI / build (pull_request) Successful in 29s
CI / runtimes (edge) (pull_request) Successful in 19s
CI / runtimes (deno) (pull_request) Successful in 33s
CARD-26 made the WebSocket route pump await `drained()` before each pull,
but mesh RPC traffic sends outside that pump, so it never waited:

- teapot: `handleRpc` runs concurrently per rpc-req, so a teacup that
  keeps sending requests and stops reading grows the teapot's buffer by
  one response each.
- link: `sendRpc` sent each rpc-req at once, whatever the buffer held.

Both now wait for `drained()` before sending. The teapot drops a response
whose socket closed while waiting. The link starts its timeout before
waiting, so a teapot that stops reading still answers 504, and a call
that settles while waiting (timeout or close) is never sent late.

Found in the pre-freeze integrated review.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-24 13:57:35 -05:00
5 changed files with 30 additions and 48 deletions

No files matched your search

Generated
+2 -3
View File
@@ -56,10 +56,9 @@
"uuid": "11.1.1"
}
},
"undici": "7.30.1",
"undici": "7.29.1",
"sharp": "0.35.5",
"fastify": "$fastify",
"multer": "2.5.0"
"fastify": "$fastify"
}
}
}
+24 -24
View File
@@ -1814,9 +1814,9 @@
}
},
"node_modules/@nestjs/platform-express": {
"version": "11.2.8",
"resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-11.2.8.tgz",
"integrity": "sha512-aSAAz8E31qv+sDsL0s7Cw/HoXmeM0TVf35ny17BjLL10c2PgFDp2vunycL7muVyp3/IP5TStMb3Ia4B/RTNHZA==",
"version": "11.2.7",
"resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-11.2.7.tgz",
"integrity": "sha512-+F0hV/4yJM+D/Qwyo5XmKMe6YGEb+ssT2jFWrgdFe1obumXCUeC1GNob/kNeXyzAXm7dcxZVUtmcoqaF6z36jA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -3164,19 +3164,19 @@
"license": "MIT"
},
"node_modules/body-parser": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
"integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
"dev": true,
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
"content-type": "^2.1.0",
"content-type": "^2.0.0",
"debug": "^4.4.3",
"http-errors": "^2.0.1",
"iconv-lite": "^0.7.3",
"iconv-lite": "^0.7.2",
"on-finished": "^2.4.1",
"qs": "^6.16.1",
"qs": "^6.15.2",
"raw-body": "^3.0.2",
"type-is": "^2.1.0"
},
@@ -3189,9 +3189,9 @@
}
},
"node_modules/body-parser/node_modules/content-type": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
"integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -4267,9 +4267,9 @@
"license": "MIT"
},
"node_modules/fast-uri": {
"version": "3.1.9",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
"integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz",
"integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==",
"dev": true,
"funding": [
{
@@ -5545,9 +5545,9 @@
"license": "MIT"
},
"node_modules/multer": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",
"integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.4.0.tgz",
"integrity": "sha512-7dqa0ZcFfzbefdTuIkzOSMvZWC0J7FLqBOjJUZvDCXShIURWKxAyTT1wHhnE5q19c7jOJf43IYYKjBmZVZmvhg==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -6196,9 +6196,9 @@
}
},
"node_modules/qs": {
"version": "6.16.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz",
"integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==",
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -7808,9 +7808,9 @@
}
},
"node_modules/undici": {
"version": "7.30.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.30.1.tgz",
"integrity": "sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==",
"version": "7.29.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.29.1.tgz",
"integrity": "sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==",
"dev": true,
"license": "MIT",
"engines": {
+2 -3
View File
@@ -130,10 +130,9 @@
"uuid": "11.1.1"
}
},
"undici": "7.30.1",
"undici": "7.29.1",
"sharp": "0.35.5",
"fastify": "$fastify",
"multer": "2.5.0"
"fastify": "$fastify"
},
"devDependencies": {
"@eslint/js": "^9.39.5",
+2 -4
View File
@@ -191,10 +191,8 @@ function tagged(
): Buffered {
const key = findHeader(result.headers, 'etag');
const existing = key === undefined ? undefined : result.headers[key];
// ETag is single-valued: from an array, the last value wins, as a repeated `setHeader` would.
const own = Array.isArray(existing) ? existing[existing.length - 1] : existing;
const etag = own ?? bodyEtag(result.body);
const headers = { ...result.headers, [key ?? 'etag']: etag };
const etag = typeof existing === 'string' ? existing : bodyEtag(result.body);
const headers = key === undefined ? { ...result.headers, etag } : result.headers;
if (isNotModified(req.headers, etag)) return bodyless({ kind: 'buffered', status: 304, headers, body: '' });
-14
View File
@@ -29,12 +29,6 @@ class Handlers {
return null;
}
@Get('/own-list')
@Transformer(() => ({ headers: { ETag: ['"v6"', '"v7"'] }, body: 'v7' }))
ownList() {
return null;
}
@Post('/post')
post() {
return { n: 1 };
@@ -188,14 +182,6 @@ describe('handlers (etag: true)', () => {
expect(res.headers.get('etag')).toBe('"v7"');
});
it("T6: a handler-set ETag array is still the handler's: the last value is sent and compared", async () => {
const first = await req(etagApp, '/h/own-list');
expect(first.headers.get('etag')).toBe('"v7"');
const res = await req(etagApp, '/h/own-list', { headers: { 'if-none-match': '"v7"' } });
expect(res.status).toBe(304);
expect(res.headers.get('etag')).toBe('"v7"');
});
it('T7/T8: a list containing the tag, and *', async () => {
const etag = (await req(etagApp, '/h/json')).headers.get('etag')!;
const list = await req(etagApp, '/h/json', { headers: { 'if-none-match': `"a", ${etag}, "c"` } });