← Back to Kontasks
Fixed Reconnect Race Condition
Applied fix to prevent reconnect after successful stream completion
Output
✅ Fix Applied
Change Made
File: konui/src/console-streaming.ts
- } catch (e) {
- log('warn', 'stream', ...);
- if (navigator.onLine) {
- reconnectWithEventSource(...);
- }
- }
+ } catch (e) {
+ // Only attempt reconnect if stream didn't complete successfully
+ // This prevents the race condition where stream close triggers error
+ // after normal completion
+ if (streamComplete) {
+ log('debug', 'stream', 'Ignoring error after successful...');
+ return;
+ }
+ log('warn', 'stream', ...);
+ if (navigator.onLine) {
+ reconnectWithEventSource(...);
+ }
+ }
How It Works
The streamComplete flag is set to true when the stream finishes normally (line 279). Now, if the catch block is triggered after a successful completion (due to browser firing an error on stream close), we simply ignore it instead of attempting to reconnect.
✓ Konui Restarted
The fix is now live. The next turn that shows timing data should no longer get stuck in "RECONNECTING..." state.
What's Next?
Test by running a turn that takes long enough to generate timing data, then verify it returns to READY state.
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
konsoleconsolebug-fixstreaming
Created
6 Jan 2026, 2:44 am
Updated
6 Jan 2026, 2:44 am
Created By
claude
Raw Data
{
"id": "cf7a4f70-1275-4ebb-84e1-e8236dfe705b",
"type": "general",
"status": "completed",
"title": "Fixed Reconnect Race Condition",
"description": "Applied fix to prevent reconnect after successful stream completion",
"context": {
"output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:sans-serif;\">\n<h2 style=\"color:#22c55e;margin:0 0 16px 0;\">✅ Fix Applied</h2>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">Change Made</h3>\n<p style=\"color:#9ca3af;margin:0 0 8px 0;\">File: <code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;color:#61afef;\">konui/src/console-streaming.ts</code></p>\n<pre style=\"background:#1a1a1a;padding:12px;border-radius:4px;overflow-x:auto;font-size:0.85em;margin:0;line-height:1.6;\"><code><span style=\"color:#f87171;\">-</span> <span style=\"color:#7f848e;\">} catch (e) {</span>\n<span style=\"color:#f87171;\">-</span> <span style=\"color:#7f848e;\">log('warn', 'stream', ...);</span>\n<span style=\"color:#f87171;\">-</span> <span style=\"color:#7f848e;\">if (navigator.onLine) {</span>\n<span style=\"color:#f87171;\">-</span> <span style=\"color:#7f848e;\">reconnectWithEventSource(...);</span>\n<span style=\"color:#f87171;\">-</span> <span style=\"color:#7f848e;\">}</span>\n<span style=\"color:#f87171;\">-</span> <span style=\"color:#7f848e;\">}</span>\n\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">} catch (e) {</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#c678dd;\">// Only attempt reconnect if stream didn't complete successfully</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#c678dd;\">// This prevents the race condition where stream close triggers error</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#c678dd;\">// after normal completion</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#c678dd;font-weight:bold;\">if (streamComplete) {</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">log('debug', 'stream', 'Ignoring error after successful...');</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#c678dd;font-weight:bold;\">return;</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#c678dd;font-weight:bold;\">}</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">log('warn', 'stream', ...);</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">if (navigator.onLine) {</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">reconnectWithEventSource(...);</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">}</span>\n<span style=\"color:#98c379;\">+</span> <span style=\"color:#e0e0e0;\">}</span></code></pre>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">How It Works</h3>\n<p style=\"color:#e0e0e0;margin:0;line-height:1.6;\">The <code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;\">streamComplete</code> flag is set to <code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;color:#98c379;\">true</code> when the stream finishes normally (line 279). Now, if the catch block is triggered after a successful completion (due to browser firing an error on stream close), we simply ignore it instead of attempting to reconnect.</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#22c55e;margin:0 0 12px 0;\">✓ Konui Restarted</h3>\n<p style=\"color:#e0e0e0;margin:0;\">The fix is now live. The next turn that shows timing data should no longer get stuck in \"RECONNECTING...\" state.</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;\">\n<h4 style=\"color:#fff;margin:0 0 8px 0;\">What's Next?</h4>\n<p style=\"color:#9ca3af;margin:0;\">Test by running a turn that takes long enough to generate timing data, then verify it returns to READY state.</p>\n</div>\n</div>",
"requestedAt": "2026-01-06T01:16:00.000Z",
"requestId": "925fc764-d19a-48db-afa0-4cea9a453b3d",
"choices": [
{
"label": "Commit this fix",
"value": "Commit the console-streaming.ts fix and push to GitHub",
"primary": true
},
{
"label": "Test it first",
"value": "Let me test this fix before committing"
},
{
"label": "Done for now",
"value": "That's all for this session"
}
]
},
"createdBy": "claude",
"createdAt": "2026-01-05T16:44:18.064Z",
"updatedAt": "2026-01-05T16:44:18.263Z",
"requestId": "925fc764-d19a-48db-afa0-4cea9a453b3d",
"scope": "vibetools",
"tags": [
"konsole",
"console",
"bug-fix",
"streaming"
],
"targetUser": "claude"
}