gitoria
All repositories: gitoria
2.2 KB
// reset-peer.mjs — mission 512. A TLS server that finishes the handshake and then// resets the connection must not kill the Hybriel program with SIGPIPE (exit 141,// which took the live tracker down every few minutes). The program has to see an// ordinary fetch error, catch it with `on Error`, and run to its end (exit 0).// Below what an .hl fixture can reach: it needs a raw TLS peer that resets.import { spawn, execFileSync } from 'node:child_process';import tls from 'node:tls';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import { fileURLToPath } from 'node:url';const HERE = path.dirname(fileURLToPath(import.meta.url));const ROOT = path.resolve(HERE, '../../..');const BIN = process.env.HL_BIN || path.resolve(ROOT, 'native/zig-out/bin/hybriel');const PORT = Number(process.env.HL_TEST_PORT || 14979);const dir = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'reset-peer-'));const key = path.join(dir, 'k.pem'), cert = path.join(dir, 'c.pem');execFileSync('openssl', ['req', '-x509', '-newkey', 'rsa:2048', '-nodes', '-keyout', key, '-out', cert,'-days', '2', '-subj', '/CN=localhost', '-addext', 'subjectAltName=DNS:localhost,IP:127.0.0.1'], { stdio: 'ignore' });const server = tls.createServer({ key: fs.readFileSync(key), cert: fs.readFileSync(cert) }, (s) => {s.on('error', () => {});if (s.socket && s.socket.resetAndDestroy) s.socket.resetAndDestroy(); else s.destroy();});await new Promise((r) => server.listen(PORT, '127.0.0.1', r));const child = spawn(BIN, [path.join(HERE, 'reset_peer.hl')], {env: { ...process.env, HL_TEST_PORT: String(PORT), HL_TEST_CA: cert },stdio: ['ignore', 'pipe', 'pipe'],});let log = '';child.stdout.on('data', (d) => { log += d; });child.stderr.on('data', (d) => { log += d; });const timer = setTimeout(() => child.kill('SIGKILL'), 100000);const [code, sig] = await new Promise((r) => child.on('exit', (c, s) => r([c, s])));clearTimeout(timer);server.close();fs.rmSync(dir, { recursive: true, force: true });if (code === 0 && log.includes('survived 150')) { console.log('PASS survived 150 resets'); process.exit(0); }console.log(`FAIL exit code ${code} signal ${sig} (141 = SIGPIPE killed it)\n` + log.slice(-1500));process.exit(1);
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 9eff6627Merge branch 'f2-api-bugs' into mainGitoria
- 26117255|||PR apps API: review comments on files with spaces in their namemre
- b8796cecMerge branch 'f1-broken-json' into mainGitoria
- 2f2959c5|||PR apps API: broken JSON body gives 400 invalid_json, not 500mre
- f7c6ca07Merge branch 'ident-chooser-selector' into mainGitoria
- 691abb8e|||PR tests: find ident identity choice without the removed .choose classmre
- 16a3530fMerge branch 'heap-revert' into mainGitoria
- 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
- 13f0c342Merge branch 'hl25-records' into mainGitoria
- a002ecb7|||PR records: HL25 report, heap helper, logmre
- 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
- fefaedd2log: tracker PR-only, HL25 startedmre
- 21aa57calog: parkmre
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre