monitoring-terminal-errors
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMonitoring Terminal Errors
监控终端错误
Continuously watch a running process (dev server, test runner, build) for errors and fix them as they appear.
持续监控运行中的进程(开发服务器、测试运行器、构建工具),一旦出现错误就立即修复。
Workflow
工作流程
1. Identify the Terminal
1. 识别终端
List terminal files and find the one running the target process:
bash
head -n 10 <terminals_folder>/*.txtLook for terminals running dev servers (, , , etc.).
npm run devpnpm devpython manage.py runserver列出终端文件并找到运行目标进程的文件:
bash
head -n 10 <terminals_folder>/*.txt寻找运行开发服务器的终端(如、、等)。
npm run devpnpm devpython manage.py runserver2. Read Terminal Output
2. 读取终端输出
Read the full terminal file content. Search for error patterns:
- Stack traces:
at <function> (<file>:<line>:<col>) - Node.js: ,
Error:,TypeError:,ReferenceError:,ENOENTECONNREFUSED - Python: followed by
Traceback (most recent call last):File "<path>", line <n> - React/Next.js: ,
Unhandled Runtime Error,Error: ...Module not found - Build errors: ,
ERROR in,Failed to compileSyntaxError - Vite:
[vite] Internal server error: - TypeScript:
error TS\d+:
读取终端文件的完整内容,搜索以下错误模式:
- 堆栈跟踪:
at <function> (<file>:<line>:<col>) - Node.js:,
Error:,TypeError:,ReferenceError:,ENOENTECONNREFUSED - Python:后续跟着
Traceback (most recent call last):File "<path>", line <n> - React/Next.js:,
Unhandled Runtime Error,Error: ...Module not found - 构建错误:,
ERROR in,Failed to compileSyntaxError - Vite:
[vite] Internal server error: - TypeScript:
error TS\d+:
3. Extract the Source Location
3. 提取源代码位置
From the stack trace, extract:
- File path
- Line number
- Error message
For Node.js:
For Python:
at functionName (/path/to/file.ts:42:10)File "/path/to/file.py", line 42, in function_name从堆栈跟踪中提取:
- 文件路径
- 行号
- 错误信息
对于Node.js:
对于Python:
at functionName (/path/to/file.ts:42:10)File "/path/to/file.py", line 42, in function_name4. Navigate and Fix
4. 导航并修复
- Read the identified file around the error line
- Understand the error (missing import, type mismatch, undefined variable, etc.)
- Apply the fix
- Re-read the terminal file to confirm the server recovered (hot reload should pick it up)
- 读取错误行附近的目标文件内容
- 理解错误原因(缺失导入、类型不匹配、未定义变量等)
- 应用修复方案
- 重新读取终端文件,确认服务器已恢复(热重载应会自动生效)
5. Loop
5. 循环执行
If the server is still showing errors after the fix, repeat from step 2. Stop when:
- The terminal shows a clean "compiled successfully" or equivalent
- No new errors appear in the output
- You've made 5 attempts without resolution (report to user)
如果修复后服务器仍显示错误,从步骤2重复操作。在以下情况时停止:
- 终端显示“编译成功”或类似的无错误提示
- 输出中不再出现新的错误
- 已尝试5次仍未解决(向用户报告)
Tips
提示
- Check for in the terminal file footer — if present, the process has crashed entirely and needs a restart
exit_code - Some errors cascade — fix the first/root error and the rest often disappear
- For HMR errors, the fix might just be saving the file again to trigger a rebuild
- 检查终端文件末尾的——如果存在,说明进程已完全崩溃,需要重启
exit_code - 部分错误会连锁引发其他问题——修复第一个/根源错误后,其余错误通常会消失
- 对于HMR错误,修复方法可能只是再次保存文件以触发重新构建