Commit ec1699c
committed
fix: address PR#60 review — refCount, shutdown path, dead code, SHA-256 keys
Must-fix #1: Remove dead ensureHealthy() + reconnectCount
- ensureHealthy() was defined but never called (acquire() used direct
socket.readyState check instead). Removed entirely along with the
reconnectCount field from PooledConnection.
Must-fix #2: Replace isActive boolean with refCount for concurrent safety
- When maxConcurrentTasks > 1, multiple dispatches share the same WS
connection. The old isActive boolean meant release() from dispatch A
would mark the connection idle and start eviction timer, killing the
connection for dispatch B still in progress.
- Now: acquire() increments refCount, release() decrements. Heartbeat
and eviction only start when refCount drops to 0.
- Added concurrent acquire test that verifies: 2 acquires → 1 release
→ connection stays alive through eviction timeout → final release
→ connection properly evicted.
Must-fix #3: Add OpenClawAgentExecutor.close() + wire into index.ts stop()
- The WS pool's destroy() was never called during plugin shutdown,
leaking connections and timers on hot-reload/test scenarios.
- Added close() method to OpenClawAgentExecutor, called from the
plugin's stop() lifecycle hook.
Nice-to-have #4: Replace conn["socket"]?.readyState with conn.isOpen getter
- Added public isOpen getter to GatewayRpcConnection for type-safe
socket state checking. Pool code now uses conn.isOpen instead of
bypassing TypeScript's private access control.
Nice-to-have #5: SHA-256 buildKey instead of plaintext in Map keys
- gatewayPassword was stored as plaintext in Map keys. Now uses
crypto.createHash('sha256') to produce a one-way hash, reducing
credential surface in heap dumps.1 parent 1845fd4 commit ec1699c
3 files changed
Lines changed: 82 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
333 | 334 | | |
334 | | - | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
| |||
981 | 982 | | |
982 | 983 | | |
983 | 984 | | |
| 985 | + | |
984 | 986 | | |
985 | 987 | | |
986 | 988 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
763 | 768 | | |
764 | 769 | | |
765 | 770 | | |
| |||
990 | 995 | | |
991 | 996 | | |
992 | 997 | | |
993 | | - | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
994 | 1001 | | |
995 | 1002 | | |
996 | | - | |
997 | 1003 | | |
998 | 1004 | | |
999 | 1005 | | |
| |||
1048 | 1054 | | |
1049 | 1055 | | |
1050 | 1056 | | |
1051 | | - | |
1052 | | - | |
| 1057 | + | |
| 1058 | + | |
1053 | 1059 | | |
1054 | 1060 | | |
1055 | | - | |
| 1061 | + | |
| 1062 | + | |
1056 | 1063 | | |
1057 | 1064 | | |
1058 | 1065 | | |
| |||
1067 | 1074 | | |
1068 | 1075 | | |
1069 | 1076 | | |
1070 | | - | |
| 1077 | + | |
1071 | 1078 | | |
1072 | 1079 | | |
1073 | | - | |
1074 | 1080 | | |
1075 | 1081 | | |
1076 | | - | |
1077 | 1082 | | |
1078 | 1083 | | |
1079 | 1084 | | |
1080 | 1085 | | |
1081 | | - | |
1082 | | - | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1083 | 1089 | | |
1084 | 1090 | | |
1085 | 1091 | | |
| |||
1088 | 1094 | | |
1089 | 1095 | | |
1090 | 1096 | | |
1091 | | - | |
| 1097 | + | |
1092 | 1098 | | |
1093 | | - | |
1094 | | - | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1095 | 1105 | | |
1096 | 1106 | | |
1097 | 1107 | | |
1098 | 1108 | | |
1099 | 1109 | | |
1100 | 1110 | | |
1101 | | - | |
| 1111 | + | |
1102 | 1112 | | |
1103 | 1113 | | |
1104 | 1114 | | |
| |||
1131 | 1141 | | |
1132 | 1142 | | |
1133 | 1143 | | |
1134 | | - | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1135 | 1147 | | |
1136 | 1148 | | |
1137 | 1149 | | |
| |||
1151 | 1163 | | |
1152 | 1164 | | |
1153 | 1165 | | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | 1166 | | |
1189 | 1167 | | |
1190 | 1168 | | |
| |||
1202 | 1180 | | |
1203 | 1181 | | |
1204 | 1182 | | |
1205 | | - | |
| 1183 | + | |
1206 | 1184 | | |
1207 | 1185 | | |
1208 | 1186 | | |
| |||
1231 | 1209 | | |
1232 | 1210 | | |
1233 | 1211 | | |
1234 | | - | |
| 1212 | + | |
1235 | 1213 | | |
1236 | 1214 | | |
1237 | 1215 | | |
| |||
1275 | 1253 | | |
1276 | 1254 | | |
1277 | 1255 | | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
1278 | 1261 | | |
1279 | 1262 | | |
1280 | 1263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
| 463 | + | |
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
478 | 521 | | |
479 | 522 | | |
480 | 523 | | |
| |||
0 commit comments