mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 02:14:32 +00:00
fix(cursor): add response body handling and size limit
- Drain health check response body with res.resume() - Add 1MB body size limit in fetchModelsFromDaemon
This commit is contained in:
1 parent
88ad13ee7b
commit
36f0308a72
2 files changed
+6
No files matched your search
@@ -48,6 +48,7 @@ export async function isDaemonRunning(port: number): Promise<boolean> {
|
|||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
},
|
},
|
||||||
(res) => {
|
(res) => {
|
||||||
|
res.resume(); // Drain response body
|
||||||
resolve(res.statusCode === 200);
|
resolve(res.statusCode === 200);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -88,10 +88,15 @@ export async function fetchModelsFromDaemon(port: number): Promise<CursorModel[]
|
|||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
},
|
},
|
||||||
(res) => {
|
(res) => {
|
||||||
|
const MAX_BODY_SIZE = 1024 * 1024; // 1MB limit
|
||||||
let data = '';
|
let data = '';
|
||||||
|
|
||||||
res.on('data', (chunk) => {
|
res.on('data', (chunk) => {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
|
if (data.length > MAX_BODY_SIZE) {
|
||||||
|
req.destroy();
|
||||||
|
resolve(DEFAULT_CURSOR_MODELS);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
|
|||||||
Reference in new issue
Block a user