Commit a5c3816
fix(mcp): timeout aborts Mocha runner so next run_test isn't blocked
Previously the run_test / run_step_by_step timeout was just a setTimeout
that rejected the race promise — the Mocha runner kept going, the
recorder chain stayed queued, listeners stayed attached, and pause
sessions kept trapping. Subsequent run_test calls hit "Mocha instance
is currently running". cancel didn't help because pendingRunPromise was
only assigned in the paused branch, so it saw nothing to cancel.
- Assign pendingRunPromise immediately after runPromise creation in
both run_test and run_step_by_step (was set only on pause).
- Wrap the Promise.race in try/catch + finally; clear the setTimeout
and route timeout rejections through cancelRun(); return a clean
status: "failed" payload to the client.
- Make cancelRun() actually abort: look up the Mocha runner via
mocha._runner / _previousRunner / runner and call runner.abort();
recorder.reset() to drop any queued tasks. Existing abortRun + pause
release stay in place for stuck-on-pause cases.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 4f0fa49 commit a5c3816
1 file changed
Lines changed: 42 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
404 | 412 | | |
405 | 413 | | |
406 | 414 | | |
| |||
1025 | 1033 | | |
1026 | 1034 | | |
1027 | 1035 | | |
| 1036 | + | |
1028 | 1037 | | |
1029 | 1038 | | |
1030 | 1039 | | |
1031 | 1040 | | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1037 | 1056 | | |
1038 | 1057 | | |
1039 | | - | |
1040 | 1058 | | |
1041 | 1059 | | |
1042 | 1060 | | |
| |||
1046 | 1064 | | |
1047 | 1065 | | |
1048 | 1066 | | |
| 1067 | + | |
1049 | 1068 | | |
1050 | 1069 | | |
1051 | 1070 | | |
| |||
1121 | 1140 | | |
1122 | 1141 | | |
1123 | 1142 | | |
| 1143 | + | |
1124 | 1144 | | |
1125 | 1145 | | |
1126 | 1146 | | |
1127 | 1147 | | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1133 | 1163 | | |
1134 | 1164 | | |
1135 | | - | |
1136 | 1165 | | |
1137 | 1166 | | |
1138 | 1167 | | |
| |||
1142 | 1171 | | |
1143 | 1172 | | |
1144 | 1173 | | |
| 1174 | + | |
1145 | 1175 | | |
1146 | 1176 | | |
1147 | 1177 | | |
| |||
0 commit comments