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:
Tam Nhu Tran
2026-02-12 07:24:10 +07:00
parent 88ad13ee7b
commit 36f0308a72
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -48,6 +48,7 @@ export async function isDaemonRunning(port: number): Promise<boolean> {
timeout: 3000,
},
(res) => {
res.resume(); // Drain response body
resolve(res.statusCode === 200);
}
);
+5
View File
@@ -88,10 +88,15 @@ export async function fetchModelsFromDaemon(port: number): Promise<CursorModel[]
timeout: 5000,
},
(res) => {
const MAX_BODY_SIZE = 1024 * 1024; // 1MB limit
let data = '';
res.on('data', (chunk) => {
data += chunk;
if (data.length > MAX_BODY_SIZE) {
req.destroy();
resolve(DEFAULT_CURSOR_MODELS);
}
});
res.on('end', () => {