Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(release): stream git log so release notes survive long tag spans\n\n`generate-release-notes.mjs` read `git log` through `execFileSync`, which\nbuffers the child's entire stdout and throws `spawnSync git ENOBUFS` past\nNode's 1 MiB `maxBuffer` default. Release Production for v0.63.21 died there:\n\n [release-notes] Collecting tinyhumansai/openhuman changes from v0.63.12 to v0.63.21\n [release-notes] spawnSync git ENOBUFS\n\nThe range is v0.63.12..v0.63.21 because nothing has published since v0.63.12,\nand the collector's output grows with the span: 394 KB at v0.63.17 (which\nreleased fine on 2026-08-21) against 1,178,143 bytes at v0.63.21 — 112% of the\nbuffer. Raising `maxBuffer` would only move the wall, since the span keeps\ngrowing; stream the output instead so there is no ceiling to cross.\n\n- `collectCommits` and `priorAuthorKeys` now stream git's stdout through an\n incremental record splitter that carries partial records across chunk\n boundaries. `priorAuthorKeys` walks the full history and so was unbounded by\n construction, not just by span.\n- The fallback step's warning claimed the AI step "failed or timed out". Both\n steps died on the same ENOBUFS; `continue-on-error` hid it and the wording\n misdirected the investigation. Report the step outcome instead of a cause.\n- ci-lite's `scripts` filter matched `scripts/*.mjs`, one directory above this\n file, so its existing node --test suite never ran when it changed.\n

M3gA-Minddb6964e54344
diff --git a/.github/workflows/ci-lite.yml b/.github/workflows/ci-lite.yml
index 1be049975f..1f818b4fc5 100644
--- a/.github/workflows/ci-lite.yml
+++ b/.github/workflows/ci-lite.yml
@@ -230,6 +230,11 @@ jobs:
- 'scripts/mock-api/**'
- 'scripts/*.mjs'
- 'scripts/__tests__/**'
+ # The release-notes generator has node --test coverage in
+ # scripts/__tests__/ but lives one directory down, so the
+ # 'scripts/*.mjs' glob above never armed this lane for it — its
+ # tests could not have caught the v0.63.21 git ENOBUFS regression.
+ - 'scripts/release/*.mjs'
# Bash helpers with node --test coverage in scripts/__tests__/.
- 'scripts/ci/assert-coverage-presence.sh'
# Shared logic behind the gate CLIs, and the module-pin gate's own
diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml
index 8e26450336..acf474ea81 100644
--- a/.github/workflows/release-production.yml
+++ b/.github/workflows/release-production.yml
@@ -292,7 +292,10 @@ jobs:
TAG: ${{ needs.prepare-build.outputs.tag }}
run: |
set -euo pipefail
- echo "::warning::AI release notes failed or timed out — using deterministic notes."
+ # `continue-on-error` hides the AI step's real failure, so this warning
+ # must not assert a cause: on v0.63.21 both steps died on the same git
+ # ENOBUFS and the "timed out" wording sent the investigation the wrong way.
+ echo "::warning::AI release notes step did not succeed (outcome=${{ steps.ai-notes.outcome }}) — using deterministic notes. See the 'Generate AI release notes' step log for the reason."
node scripts/release/generate-release-notes.mjs \
--from latest-release \
--to "$TAG" \
diff --git a/scripts/__tests__/generate-release-notes.test.mjs b/scripts/__tests__/generate-release-notes.test.mjs
index 6b6c560aaa..bcae38897f 100644
--- a/scripts/__tests__/generate-release-notes.test.mjs
+++ b/scripts/__tests__/generate-release-notes.test.mjs
@@ -1,14 +1,21 @@
import assert from 'node:assert/strict';
+import { execFileSync } from 'node:child_process';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
import { test } from 'node:test';
import {
buildOpenAiRequest,
buildReleasePayload,
+ collectCommits,
+ createRecordSplitter,
ensureAllPullRequestsLinked,
extractPullRequestNumbers,
parseArgs,
parseGitHubRepoFromRemote,
parseGitLog,
+ priorAuthorKeys,
renderDeterministicNotes,
} from '../release/generate-release-notes.mjs';
@@ -211,3 +218,97 @@ test('deterministic notes omit new contributors section when there are none', ()
const markdown = renderDeterministicNotes({ title: 'v1.0.0 to main', payload });
assert.doesNotMatch(markdown, /## New Contributors/);
});
+
+test('record splitter reassembles records across chunk boundaries', () => {
+ const records = [];
+ const splitter = createRecordSplitter('\x1e', (record) => records.push(record));
+
+ // A separator straddling two chunks is the failure mode a naive
+ // `chunk.split(sep)` reader gets wrong, so feed one byte at a time.
+ const stream = 'alpha\x1ebeta\x1egamma';
+ for (const character of stream) {
+ splitter.push(character);
+ }
+ assert.deepEqual(records, ['alpha', 'beta']);
+
+ // The final record has no trailing separator; end() must still emit it.
+ splitter.end();
+ assert.deepEqual(records, ['alpha', 'beta', 'gamma']);
+
+ // end() is idempotent — a second call must not re-emit.
+ splitter.end();
+ assert.deepEqual(records, ['alpha', 'beta', 'gamma']);
+});
+
+test('commit collection survives a git log larger than the 1 MiB spawn buffer', async (t) => {
+ // Regression guard for the v0.63.21 release failure: `execFileSync` buffers the
+ // child's whole stdout and throws `spawnSync git ENOBUFS` past Node's 1 MiB
+ // `maxBuffer` default. The release span grows with every unpublished tag, so the
+ // collector must not have a fixed output ceiling at all.
+ const MAX_BUFFER_BYTES = 1024 * 1024;
+ const repo = mkdtempSync(join(tmpdir(), 'release-notes-enobufs-'));
+ t.after(() => rmSync(repo, { recursive: true, force: true }));
+
+ // Ignore the ambient git config: a developer's global `commit.gpgsign` or
+ // `tag.gpgSign` would otherwise make the fixture prompt or fail.
+ const git = (...args) =>
+ execFileSync('git', args, {
+ cwd: repo,
+ encoding: 'utf8',
+ stdio: ['ignore', 'pipe', 'pipe'],
+ env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null' },
+ });
+
+ git('init', '--quiet', '--initial-branch', 'main');
+ git('config', 'user.name', 'Range Fixture');
+ git('config', 'user.email', '[email protected]');
+ git('config', 'commit.gpgsign', 'false');
+ git('config', 'tag.gpgSign', 'false');
+ git('commit', '--allow-empty', '--quiet', '-m', 'base');
+ git('tag', 'start');
+
+ const COMMITS = 150;
+ const SUBJECT_PADDING = 8000;
+ for (let index = 0; index < COMMITS; index += 1) {
+ git(
+ 'commit',
+ '--allow-empty',
+ '--quiet',
+ '-m',
+ `chore: padded commit ${index} ${'x'.repeat(SUBJECT_PADDING)} (#${1000 + index})`,
+ );
+ }
+ git('tag', 'end');
+
+ const previousCwd = process.cwd();
+ process.chdir(repo);
+ t.after(() => process.chdir(previousCwd));
+
+ // The fixture is only a regression guard if it actually overflows the buffer
+ // the old implementation used.
+ const rawBytes = Buffer.byteLength(
+ execFileSync(
+ 'git',
+ ['log', 'start..end', '--reverse', '--format=%H%x1f%s%x1f%an%x1f%ae%x1f%aI%x1e'],
+ {
+ cwd: repo,
+ encoding: 'utf8',
+ maxBuffer: 64 * 1024 * 1024,
+ env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null' },
+ },
+ ),
+ );
+ assert.ok(
+ rawBytes > MAX_BUFFER_BYTES,
+ `fixture must exceed the 1 MiB spawn buffer, got ${rawBytes} bytes`,
+ );
+
+ const commits = await collectCommits('start', 'end');
+ assert.equal(commits.length, COMMITS);
+ assert.equal(commits.at(0).primaryPrNumber, 1000);
+ assert.equal(commits.at(-1).primaryPrNumber, 1000 + COMMITS - 1);
+ assert.ok(commits.every((commit) => commit.sha.length === 40));
+
+ const priorKeys = await priorAuthorKeys('start');
+ assert.ok(priorKeys.has('range fixture <[email protected]>'));
+});
diff --git a/scripts/release/generate-release-notes.mjs b/scripts/release/generate-release-notes.mjs
index fa2ed47a00..8f3f59222b 100644
--- a/scripts/release/generate-release-notes.mjs
+++ b/scripts/release/generate-release-notes.mjs
@@ -1,5 +1,5 @@
#!/usr/bin/env node
-import { execFileSync } from 'node:child_process';
+import { execFileSync, spawn } from 'node:child_process';
import { existsSync, writeFileSync } from 'node:fs';
import { basename, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
@@ -103,6 +103,80 @@ function runGh(args, options = {}) {
}).trim();
}
+const RECORD_SEPARATOR = '\x1e';
+
+/**
+ * Split a byte stream into separator-delimited records without ever holding the
+ * whole stream in memory. Chunk boundaries land anywhere, including inside a
+ * record, so the tail of each chunk is carried into the next one.
+ */
+export function createRecordSplitter(separator, onRecord) {
+ let pending = '';
+ return {
+ push(chunk) {
+ pending += chunk;
+ let index = pending.indexOf(separator);
+ while (index !== -1) {
+ onRecord(pending.slice(0, index));
+ pending = pending.slice(index + separator.length);
+ index = pending.indexOf(separator);
+ }
+ },
+ end() {
+ if (pending) {
+ onRecord(pending);
+ pending = '';
+ }
+ },
+ };
+}
+
+/**
+ * Run git and hand each separator-delimited record to `onRecord` as it arrives.
+ *
+ * `execFileSync` buffers the child's entire stdout and dies with ENOBUFS once it
+ * passes Node's 1 MiB `maxBuffer` default. The release ranges this script walks
+ * grow with every unpublished tag, so a buffered read is a ratchet that is
+ * guaranteed to break again at some future span. Streaming has no such ceiling.
+ */
+function streamGitRecords(args, onRecord, options = {}) {
+ const separator = options.separator || RECORD_SEPARATOR;
+ return new Promise((resolvePromise, reject) => {
+ const child = spawn('git', args, { stdio: ['ignore', 'pipe', 'pipe'] });
+ const splitter = createRecordSplitter(separator, onRecord);
+ let stderr = '';
+
+ child.stdout.setEncoding('utf8');
+ child.stdout.on('data', (chunk) => {
+ try {
+ splitter.push(chunk);
+ } catch (error) {
+ child.kill();
+ reject(error);
+ }
+ });
+ child.stderr.setEncoding('utf8');
+ child.stderr.on('data', (chunk) => {
+ stderr += chunk;
+ });
+
+ child.on('error', reject);
+ child.on('close', (code) => {
+ if (code !== 0) {
+ reject(new Error(`git ${args.join(' ')} exited with code ${code}${stderr ? `: ${stderr.trim()}` : ''}`));
+ return;
+ }
+ try {
+ splitter.end();
+ } catch (error) {
+ reject(error);
+ return;
+ }
+ resolvePromise();
+ });
+ });
+}
+
export function parseGitHubRepoFromRemote(remoteUrl) {
const cleaned = String(remoteUrl || '').trim().replace(/\.git$/, '');
const sshMatch = cleaned.match(/github\.com[:/]([^/\s]+\/[^/\s]+)$/);
@@ -167,46 +241,53 @@ export function extractPullRequestNumbers(subject) {
return [...new Set(matches.map((match) => Number(match[1])).filter(Number.isInteger))];
}
+function parseCommitRecord(entry) {
+ const [sha, subject, authorName, authorEmail, authoredAt] = entry.split('\x1f');
+ const prNumbers = extractPullRequestNumbers(subject);
+ return {
+ sha,
+ shortSha: sha.slice(0, 9),
+ subject,
+ authorName,
+ authorEmail,
+ authoredAt,
+ prNumbers,
+ primaryPrNumber: prNumbers.at(-1) || null,
+ };
+}
+
export function parseGitLog(logText) {
if (!logText.trim()) {
return [];
}
return logText
- .split('\x1e')
+ .split(RECORD_SEPARATOR)
.map((entry) => entry.trim())
.filter(Boolean)
- .map((entry) => {
- const [sha, subject, authorName, authorEmail, authoredAt] = entry.split('\x1f');
- const prNumbers = extractPullRequestNumbers(subject);
- return {
- sha,
- shortSha: sha.slice(0, 9),
- subject,
- authorName,
- authorEmail,
- authoredAt,
- prNumbers,
- primaryPrNumber: prNumbers.at(-1) || null,
- };
- });
+ .map(parseCommitRecord);
}
-function collectCommits(from, to) {
+export async function collectCommits(from, to) {
const format = '%H%x1f%s%x1f%an%x1f%ae%x1f%aI%x1e';
- const output = runGit(['log', `${from}..${to}`, '--reverse', `--format=${format}`]);
- return parseGitLog(output);
+ const commits = [];
+ await streamGitRecords(['log', `${from}..${to}`, '--reverse', `--format=${format}`], (entry) => {
+ const trimmed = entry.trim();
+ if (trimmed) {
+ commits.push(parseCommitRecord(trimmed));
+ }
+ });
+ return commits;
}
-function priorAuthorKeys(from) {
- const output = runGit(['log', from, '--format=%an%x1f%ae%x1e']);
+export async function priorAuthorKeys(from) {
const keys = new Set();
- for (const entry of output.split('\x1e')) {
+ await streamGitRecords(['log', from, '--format=%an%x1f%ae%x1e'], (entry) => {
const [name, email] = entry.trim().split('\x1f');
if (name || email) {
keys.add(authorKey({ authorName: name, authorEmail: email }));
}
- }
+ });
return keys;
}
@@ -671,8 +752,8 @@ async function main() {
assertRefExists(resolvedTo, 'End');
console.error(`[release-notes] Collecting ${repo} changes from ${from} to ${resolvedTo}`);
- const commits = collectCommits(from, resolvedTo);
- const contributors = collectContributorStats(commits, priorAuthorKeys(from));
+ const commits = await collectCommits(from, resolvedTo);
+ const contributors = collectContributorStats(commits, await priorAuthorKeys(from));
const pullRequests = collectPullRequests(repo, commits);
const payload = buildReleasePayload({
from,