diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-12 16:00:23 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:16 -0300 |
| commit | 48281b473571d93d5a35d2250213902d1411de40 (patch) | |
| tree | 1800004710583d5b73d73775bf0e5326814fcc25 /test/web | |
| parent | d4dfee52a67d2e2b9a52f7e7b18b3b3cc185fac4 (diff) | |
| download | cloud9-48281b473571d93d5a35d2250213902d1411de40.tar.gz cloud9-48281b473571d93d5a35d2250213902d1411de40.zip | |
9web: allow HTTP listener restarts without sharing live ports
Set SO_REUSEADDR before binding Linux HTTP sockets so recent connections do not block a systemd restart. Avoid SO_REUSEPORT: the std.Io combined reuse option would permit another live process to bind the same endpoint. Return the listener to std.Io for cancellable accepts.
Exercise immediate dashboard/site restarts after HTTP traffic and rejection of a competing live listener in the Chromium suite. Catalogue, HTTP filesystem and all 32 original E2E scenarios also pass.
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/catalog_ui.mjs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/web/catalog_ui.mjs b/test/web/catalog_ui.mjs index bed40b2..d030842 100644 --- a/test/web/catalog_ui.mjs +++ b/test/web/catalog_ui.mjs @@ -119,6 +119,15 @@ try { assert.equal(await evaluate(`document.documentElement.scrollWidth <= innerWidth`), true, 'mobile page does not overflow'); await fs.writeFile('.zig-cache/catalog-ui/mobile.png', Buffer.from((await cdp('Page.captureScreenshot', { format: 'png' })).data, 'base64')); assert.deepEqual(exceptions, []); + // A live port remains exclusive, but TIME_WAIT must not break a restart. + const competitor = start(binary, ['--listen', `127.0.0.1:${dashboard}`]); + await wait(() => competitor.exitCode !== null, 'competing listener refused'); + assert.notEqual(competitor.exitCode, 0); + assert.match(competitor.output, /address already in use/); + web.kill('SIGTERM'); await once(web, 'exit'); + await fs.unlink(path.join(work, 'catalog.sock')); + start(binary, ['--listen', `127.0.0.1:${dashboard}`, '--catalog', path.join(work, 'config.json'), '--catalog-socket', path.join(work, 'catalog.sock'), '--state-dir', path.join(work, 'state')]); + await wait(async () => (await fetch(url)).ok && (await fetch(`http://127.0.0.1:${sitePort}`)).ok, 'immediate restart with recent HTTP traffic'); console.log('catalog_ui: shared shell/style, tab history, file/log navigation, build control, focus, dirty edits and mobile layout passed'); } catch (e) { for (const child of children) console.error(child.output.slice(-5000)); |
