Description
Summary
OpenCode Desktop's in-app browser intermittently returns empty HTTP 502 responses when plain-HTTP requests overlap. This makes local development pages render without CSS, JavaScript, fonts, or images. A framework-free HTTP fixture reproduces the failure, and the failed requests never reach its HTTP handler.
Environment
- opencode version: Desktop 2.2.0 (browser User-Agent); connected server 2.2.0 (
opencode api get /api/info). Also observed earlier with Desktop 2.1.4.
- OS: Desktop macOS (exact version unavailable); connected server Linux 7.0.14 aarch64, glibc 2.43.
- Browser runtime: Electron 44.9.1 / Chromium 152.0.7977.167, per User-Agent.
- Terminal: Server TERM=xterm-256color; desktop terminal not applicable.
- Shell: Server /bin/bash.
- Install/channel: Installed Desktop app; exact channel unavailable. Server runtime reports channel latest. No matching desktop update was offered when initially investigated.
- Active plugins: Configured project plugin opencode-zeldoc; built-in browser plugin active. Other desktop plugin state unavailable.
- Topology: Browser UI runs on macOS; tool execution and the connected server run in Linux. Preview localhost traffic resolves on that connected server, per the browser tool contract.
Reproduction
On the connected server, run this minimal Node HTTP server:
const http = require('node:http');
const seen = [];
http.createServer((req, res) => {
const url = new URL(req.url, 'http://127.0.0.1');
if (url.pathname === '/observations') {
res.setHeader('content-type', 'application/json');
return res.end(JSON.stringify(seen));
}
if (url.pathname === '/asset') {
seen.push(url.searchParams.get('id'));
res.setHeader('content-type', 'text/plain');
return res.end('diagnostic asset');
}
res.setHeader('content-type', 'text/html');
res.end('<!doctype html><title>Proxy diagnostic</title><h1>Proxy diagnostic</h1>');
}).listen(3107, '127.0.0.1');
Open http://127.0.0.1:3107/ in OpenCode's in-app browser.
Evaluate this script in that browser tab using browser.evaluate:
(async () => {
const results = [];
for (const count of [1, 6, 12]) {
const batch = Date.now();
const responses = await Promise.all(
Array.from({ length: count }, async (_, i) => {
const id = `${batch}-${count}-${i}`;
try {
const response = await fetch(`/asset?id=${id}`);
return { id, status: response.status, body: await response.text() };
} catch (error) {
return { id, error: String(error) };
}
})
);
results.push({ count, responses });
}
return results;
})()
Compare successful IDs with curl http://127.0.0.1:3107/observations from the connected server.
Expected Behavior
All requests return HTTP 200 with diagnostic asset. Normal local development pages load their supporting assets.
Actual Behavior
One captured fixture run:
Concurrent requests | HTTP 200 | Empty HTTP 502
-- | -- | --
1 | 1 | 0
6 | 2 | 4
12 | 1 | 11
Only the four successful requests appeared in the fixture's /observations output. The failed requests did not reach its HTTP handler.
The failure rate and threshold vary between runs. Some 502s arrive within roughly 6–14 ms; others take several hundred milliseconds. This is not established as a fixed connection limit.
Additional Context
- Reproduces without Next.js, Uniform, CSP, external assets, or response compression. The minimal fixture has none of them.
- The original symptom is HTML rendering without styles and functioning client-side JavaScript. Network diagnostics show empty 502 responses for CSS, JS, and fonts.
- Twelve concurrent direct requests to the original development server all returned 200.
- Loading the same CSS URL alone through the preview succeeds. Staggering four requests by 150 ms made all four succeed in the tested batch.
- Also reproduced against public
http://example.com: four of six parallel requests returned 502. The tested six-request batch to https://example.com returned six 200s. This suggests a plain-HTTP forwarding-path difference, not proof that all HTTPS workloads are unaffected.
- Restarting Desktop restored general navigation after it stopped loading even external sites, but did not resolve the concurrent HTTP asset failures. Both localhost and 127.0.0.1 were tested.
- A reduced Node harness using the v2.2.0 proxy and server tunnel source (commit
1097e2668b1e08ad63bdf0b1c4860b9bc01e420c), connected via a substitute HTTP transport, passes batches up to 24 concurrent requests. It also passes with Effect 4.0.1 and @effect/platform-node 4.0.1's Node HTTP client. It is not the complete authenticated RPC/Electron integration, so this does not identify the exact fault.
- In
packages/plugin-browser/src/proxy.ts, forwarding exceptions become empty 502s without preserving the exception in that handler. Capturing the first failed tunnel operation and safe nested RPC error would help locate the failure.
- Stale CLOSE_WAIT sockets were observed in the installed server, but no increasing leak or exhausted 64-connection limit has been demonstrated; this remains unconfirmed.
- No security settings or installed OpenCode binaries were modified. Chrome is the working workaround. No precise root cause or fix is claimed.
Summary
OpenCode Desktop's in-app browser intermittently returns empty HTTP 502 responses when plain-HTTP requests overlap. This makes local development pages render without CSS, JavaScript, fonts, or images. A framework-free HTTP fixture reproduces the failure, and the failed requests never reach its HTTP handler.
Environment
opencode version: Desktop 2.2.0 (browser User-Agent); connected server 2.2.0 (opencode api get /api/info). Also observed earlier with Desktop 2.1.4.
OS: Desktop macOS (exact version unavailable); connected server Linux 7.0.14 aarch64, glibc 2.43.
Browser runtime: Electron 44.9.1 / Chromium 152.0.7977.167, per User-Agent.
Terminal: Server TERM=xterm-256color; desktop terminal not applicable.
Shell: Server /bin/bash.
Install/channel: Installed Desktop app; exact channel unavailable. Server runtime reports channel latest. No matching desktop update was offered when initially investigated.
Active plugins: Configured project plugin opencode-zeldoc; built-in browser plugin active. Other desktop plugin state unavailable.
Topology: Browser UI runs on macOS; tool execution and the connected server run in Linux. Preview localhost traffic resolves on that connected server, per the browser tool contract.
Reproduction
On the connected server, run this minimal Node HTTP server:
const http = require('node:http');
const seen = [];
http.createServer((req, res) => {
const url = new URL(req.url, 'http://127.0.0.1');
if (url.pathname === '/observations') {
res.setHeader('content-type', 'application/json');
return res.end(JSON.stringify(seen));
}
if (url.pathname === '/asset') {
seen.push(url.searchParams.get('id'));
res.setHeader('content-type', 'text/plain');
return res.end('diagnostic asset');
}
res.setHeader('content-type', 'text/html');
res.end('<!doctype html><title>Proxy diagnostic</title>
Proxy diagnostic
');
}).listen(3107, '127.0.0.1');
Open
http://127.0.0.1:3107/ in OpenCode's in-app browser.
Evaluate this script in that browser tab using browser.evaluate:
(async () => {
const results = [];
for (const count of [1, 6, 12]) {
const batch = Date.now();
const responses = await Promise.all(
Array.from({ length: count }, async (_, i) => {
const id =
${batch}-${count}-${i};
try {
const response = await fetch(
/asset?id=${id});
return { id, status: response.status, body: await response.text() };
} catch (error) {
return { id, error: String(error) };
}
})
);
results.push({ count, responses });
}
return results;
})()
Compare successful IDs with curl
http://127.0.0.1:3107/observations from the connected server.
Expected Behavior
All requests return HTTP 200 with diagnostic asset. Normal local development pages load their supporting assets.
Actual Behavior
One captured fixture run:
Concurrent requests HTTP 200 Empty HTTP 502
1 1 0
6 2 4
12 1 11
Only the four successful requests appeared in the fixture's /observations output. The failed requests did not reach its HTTP handler.
The failure rate and threshold vary between runs. Some 502s arrive within roughly 6–14 ms; others take several hundred milliseconds. This is not established as a fixed connection limit.
Additional Context
Reproduces without Next.js, Uniform, CSP, external assets, or response compression. The minimal fixture has none of them.
The original symptom is HTML rendering without styles and functioning client-side JavaScript. Network diagnostics show empty 502 responses for CSS, JS, and fonts.
Twelve concurrent direct requests to the original development server all returned 200.
Loading the same CSS URL alone through the preview succeeds. Staggering four requests by 150 ms made all four succeed in the tested batch.
Also reproduced against public http://example.com/: four of six parallel requests returned 502. The tested six-request batch to https://example.com/ returned six 200s. This suggests a plain-HTTP forwarding-path difference, not proof that all HTTPS workloads are unaffected.
Restarting Desktop restored general navigation after it stopped loading even external sites, but did not resolve the concurrent HTTP asset failures. Both localhost and 127.0.0.1 were tested.
A reduced Node harness using the v2.2.0 proxy and server tunnel source (commit 1097e26), connected via a substitute HTTP transport, passes batches up to 24 concurrent requests. It also passes with Effect 4.0.1 and @effect/platform-node 4.0.1's Node HTTP client. It is not the complete authenticated RPC/Electron integration, so this does not identify the exact fault.
In packages/plugin-browser/src/proxy.ts, forwarding exceptions become empty 502s without preserving the exception in that handler. Capturing the first failed tunnel operation and safe nested RPC error would help locate the failure.
Stale CLOSE_WAIT sockets were observed in the installed server, but no increasing leak or exhausted 64-connection limit has been demonstrated; this remains unconfirmed.
No security settings or installed OpenCode binaries were modified. Chrome is the working workaround. No precise root cause or fix is claimed.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot
No response
Operating System
No response
Terminal
No response