Skip to content

Implement atomic file operations for URL fetch caching - #14843

Closed
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/use-atomic-fetch-rename
Closed

Implement atomic file operations for URL fetch caching#14843
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/use-atomic-fetch-rename

Conversation

CopilotAI commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

URL content caching in runtime_import.cjs was vulnerable to race conditions and partial writes when multiple workflow runs fetched the same URL concurrently.

Changes

  • Atomic write-then-rename pattern in fetchUrlContent():
    • Write to temporary file: ${cacheFile}.tmp.${process.pid}.${Date.now()}
    • Atomic rename via fs.renameSync() (POSIX guarantee)
    • Cleanup temp file on error
// Write to temporary file firstconsttempFile=`${cacheFile}.tmp.${process.pid}.${Date.now()}`;fs.writeFileSync(tempFile,data,"utf8");// Atomic rename - file is either complete or absentfs.renameSync(tempFile,cacheFile);

This ensures cache files are never partially written - concurrent readers either see the complete file or no file at all.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Implement atomic fetch and rename for URLs in JavaScriptImplement atomic file operations for URL fetch cachingFeb 10, 2026
CopilotAI requested a review from pelikhanFebruary 10, 2026 22:06
@github-actions
github-actionsBot deleted the copilot/use-atomic-fetch-rename branch April 2, 2026 13:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@pelikhan