From c06ca1db7938c483dcd1b89bb88bf430fd048cdd Mon Sep 17 00:00:00 2001 From: snlavaise Date: Wed, 12 Aug 2026 03:35:41 +0000 Subject: [PATCH] fix: Corregir scroll del emulador y serializacion circular de FindCursor en mongosh --- server/api-mongodb.js | 10 ++++++++-- src/sections/SeccionSistema.tsx | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/api-mongodb.js b/server/api-mongodb.js index 15a594d..01b57d1 100644 --- a/server/api-mongodb.js +++ b/server/api-mongodb.js @@ -828,8 +828,14 @@ app.post('/api/admin/mongosh', async (req, res) => { })(); `); - const result = await evalFn(dbProxy, ObjectId); - res.json({ result }); + let finalResult = await evalFn(dbProxy, ObjectId); + + // Si el resultado es un cursor de MongoDB (ej. db.collection.find()), lo convertimos a array + if (finalResult && typeof finalResult === 'object' && typeof finalResult.toArray === 'function') { + finalResult = await finalResult.toArray(); + } + + res.json({ result: finalResult }); } catch (err) { res.status(400).json({ error: err.message || String(err) }); } diff --git a/src/sections/SeccionSistema.tsx b/src/sections/SeccionSistema.tsx index 9cd9202..62fda2f 100644 --- a/src/sections/SeccionSistema.tsx +++ b/src/sections/SeccionSistema.tsx @@ -169,7 +169,7 @@ export function SeccionSistema() {
inputRef.current?.focus()} + onClick={() => inputRef.current?.focus({ preventScroll: true })} > {consoleHistory.length === 0 && (
Conectado. Esperando comandos... Ej: db.pacientes.find()
@@ -194,7 +194,7 @@ export function SeccionSistema() { setMongoshCommand(e.target.value)} onKeyDown={handleKeyDown}