Repository navigation
Closed
Labels
Description
What version of Bun is running?
1.3.11
What platform is your computer?
Linux 6.1.0-18-amd64 x86_64 unknown
What steps can reproduce the bug?
const RSS_URL = "https://www.bluetracker.gg/rss/diablo4/";
const POLL_INTERVAL_MS = 31000;
const LAST_GUID_FILE = "./last_guid.txt";
const RUN_DURATION_MS = 1 * 3600 * 1000; // 1 hour
type BluePost = {
guid: string;
title: string;
description: string;
link: string;
pubDate: string;
};
let lastSeenGuid: string | null = null;
async function loadLastGuid(): Promise<string | null> {
try {
const file = Bun.file(LAST_GUID_FILE);
if (await file.exists()) {
return await file.text();
}
} catch (e) {
console.log(`Failed to load last guid: ${e}`);
}
return null;
}
async function saveLastGuid(guid: string): Promise<void> {
try {
await Bun.write(LAST_GUID_FILE, guid);
} catch (e) {
console.log(`Failed to save last guid: ${e}`);
}
}
async function webhook(post: BluePost) {
const json = {
username: "Blues",
attachments: [{fallback: "N/A", title: post.title, title_link: post.link, text: post.description}],
};
const url = "https://removed.com/";
try {
await fetch(url, {
method: "POST",
body: JSON.stringify(json),
headers: {
"Content-Type": "application/json"
}
});
} catch (e) {
console.log(`webhook err: ${e}`);
}
}
function extractTag(block: string, tag: string): string | null {
const match = block.match(
new RegExp(`<${tag}>([\\s\\S]*?)<\\/${tag}>`, "i")
);
return match ? match[1].trim() : null;
}
function getLatestItem(xml: string): BluePost | null {
const itemMatch = xml.match(/<item>([\s\S]*?)<\/item>/i);
if (!itemMatch) return null;
const item = itemMatch[1];
return {
guid: extractTag(item, "guid") ?? "",
title: extractTag(item, "title") ?? "",
description: extractTag(item, "description") ?? "",
link: extractTag(item, "link") ?? "",
pubDate: extractTag(item, "pubDate") ?? "",
};
}
async function poll() {
try {
const res = await fetch(RSS_URL);
if (!res.ok) {
throw new Error(`RSS fetch failed: ${res.status}`);
}
const xml = await res.text();
const latest = getLatestItem(xml);
if (!latest?.guid) return;
if (latest.guid !== lastSeenGuid) {
lastSeenGuid = latest.guid;
await saveLastGuid(latest.guid);
await webhook(latest);
}
} catch (err) {
console.error("Polling error:", err);
}
}
async function main() {
lastSeenGuid = await loadLastGuid();
const startTime = Date.now();
while (Date.now() - startTime < RUN_DURATION_MS) {
await poll();
await Bun.sleep(POLL_INTERVAL_MS);
}
process.exit(0);
}
main();
Running this simple script (Made by Claude) causes memory to leak (my server with 8gb ram eventually OOM'd). I had to ask Claude to add a 1 hour max run duration to it.
Webhooks are almost never fired (maybe once a week at most) so it's likely just related to the fetch() polling.
To observe memory leak easier, simply change POLL_INTERVAL_MS to 1000.
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
Activity
robobun commentedon Mar 22, 2026
Unable to reproduce this. What I tried:
I tested a script closely mimicking yours (local HTTP server + fetch polling with regex XML parsing) on Bun 1.3.11 (Linux) with up to 50,000 iterations.
Results:
Bun.gc(true)every 5K itersNo memory leak was found. When garbage collection runs, all memory is fully reclaimed. The slow heap growth without explicit GC is normal — JSC's garbage collector doesn't trigger aggressively when there's low memory pressure. Bun actually uses significantly less memory than Node.js for the same workload.
Your script polls every 31 seconds (~116 polls/hour). At the observed growth rate without GC (~3.5 MB per 50K polls), it would take millions of polls to approach 8GB — far longer than the 1-hour runtime.
A couple of things to investigate on your end:
mainfor an HTTPS fetch memory leak with SSL config caching (commit05327256e5). Since you're fetching fromhttps://www.bluetracker.gg/, this may have affected you. Try updating to the latest Bun.If you can still reproduce the OOM after updating Bun, a minimal repro with memory snapshots (e.g., logging
process.memoryUsage()every poll) would help narrow it down.If you can provide a minimal reproduction (exact command, Bun version, platform), please update the issue.
Automated investigation. Reopen with more context if this is wrong.
ReD-GuardiaN commentedon Apr 1, 2026
The automated investigation above is incorrect. The bot tested with a local HTTP server, not real remote HTTPS fetches, which doesn't exercise the same Blob/body buffering code path.
I've reproduced this issue independently on Bun 1.3.11 (Windows) with a minimal script that fetches 50 remote files as Blobs, clears all references, then calls
Bun.gc(true)multiple times with 8 seconds of wait time.Results on the same machine:
Bun releases zero memory after dereferencing all Blobs and forcing GC. Node correctly frees ~73%.
This is the same underlying bug as #12941 (which was prematurely closed). I've opened a new issue with a clean single-file repro that works with both
bun repro.jsandnode --expose-gc repro.jsfor direct comparison.alii commentedon May 13, 2026
Couldn't reproduce this on Bun 1.3.13 (linux x64). Closing — if you're still hitting it on the latest release, please drop a fresh repro and we'll reopen.