monitoring-terminal-errors

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Monitoring 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>/*.txt
Look for terminals running dev servers (
npm run dev
,
pnpm dev
,
python manage.py runserver
, etc.).
列出终端文件并找到运行目标进程的文件:
bash
head -n 10 <terminals_folder>/*.txt
寻找运行开发服务器的终端(如
npm run dev
pnpm dev
python manage.py runserver
等)。

2. 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:
    ,
    ENOENT
    ,
    ECONNREFUSED
  • Python:
    Traceback (most recent call last):
    followed by
    File "<path>", line <n>
  • React/Next.js:
    Unhandled Runtime Error
    ,
    Error: ...
    ,
    Module not found
  • Build errors:
    ERROR in
    ,
    Failed to compile
    ,
    SyntaxError
  • Vite:
    [vite] Internal server error:
  • TypeScript:
    error TS\d+:
读取终端文件的完整内容,搜索以下错误模式:
  • 堆栈跟踪
    at <function> (<file>:<line>:<col>)
  • Node.js
    Error:
    ,
    TypeError:
    ,
    ReferenceError:
    ,
    ENOENT
    ,
    ECONNREFUSED
  • Python
    Traceback (most recent call last):
    后续跟着
    File "<path>", line <n>
  • React/Next.js
    Unhandled Runtime Error
    ,
    Error: ...
    ,
    Module not found
  • 构建错误
    ERROR in
    ,
    Failed to compile
    ,
    SyntaxError
  • 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:
at functionName (/path/to/file.ts:42:10)
For Python:
File "/path/to/file.py", line 42, in function_name
从堆栈跟踪中提取:
  • 文件路径
  • 行号
  • 错误信息
对于Node.js:
at functionName (/path/to/file.ts:42:10)
对于Python:
File "/path/to/file.py", line 42, in function_name

4. Navigate and Fix

4. 导航并修复

  1. Read the identified file around the error line
  2. Understand the error (missing import, type mismatch, undefined variable, etc.)
  3. Apply the fix
  4. Re-read the terminal file to confirm the server recovered (hot reload should pick it up)
  1. 读取错误行附近的目标文件内容
  2. 理解错误原因(缺失导入、类型不匹配、未定义变量等)
  3. 应用修复方案
  4. 重新读取终端文件,确认服务器已恢复(热重载应会自动生效)

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
    exit_code
    in the terminal file footer — if present, the process has crashed entirely and needs a restart
  • 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错误,修复方法可能只是再次保存文件以触发重新构建