mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 04:17:11 +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:
@@ -48,6 +48,7 @@ export async function isDaemonRunning(port: number): Promise<boolean> {
|
||||
timeout: 3000,
|
||||
},
|
||||
(res) => {
|
||||
res.resume(); // Drain response body
|
||||
resolve(res.statusCode === 200);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user