| 1247 | } |
| 1248 | |
| 1249 | const isTerminalConnectionError = (msg: string): boolean => { |
| 1250 | return ( |
| 1251 | msg.includes('ECONNRESET') || |
| 1252 | msg.includes('ETIMEDOUT') || |
| 1253 | msg.includes('EPIPE') || |
| 1254 | msg.includes('EHOSTUNREACH') || |
| 1255 | msg.includes('ECONNREFUSED') || |
| 1256 | msg.includes('Body Timeout Error') || |
| 1257 | msg.includes('terminated') || |
| 1258 | // SDK SSE reconnection intermediate errors — may be wrapped around the |
| 1259 | // actual network error, so the substrings above won't match |
| 1260 | msg.includes('SSE stream disconnected') || |
| 1261 | msg.includes('Failed to reconnect SSE stream') |
| 1262 | ) |
| 1263 | } |
| 1264 | |
| 1265 | // Enhanced error handler with detailed logging |
| 1266 | client.onerror = (error: Error) => { |