Skip to content

fix(node): make filesystem storage writes atomic - #330

Open
pekkahcut wants to merge 2 commits into
FhenixProtocol:masterfrom
pekkahcut:fix-node-storage-atomic-write
Open

fix(node): make filesystem storage writes atomic#330
pekkahcut wants to merge 2 commits into
FhenixProtocol:masterfrom
pekkahcut:fix-node-storage-atomic-write

Conversation

@pekkahcut

Copy link
Copy Markdown

Summary

  • write Node filesystem storage through a temporary file before replacing the persisted JSON
  • clean up the temporary file if the write or rename fails
  • add a regression test covering successful persistence and temporary-file cleanup

Problem

The Node storage implementation wrote directly to the final .cofhesdk/<name>.json file.

If the process was interrupted while that write was in progress, the existing persisted storage could be left partially written or invalid. A subsequent read would then fail to parse the JSON and fall back to in-memory storage.

Writing to a temporary file first and renaming it into place avoids exposing a partially written destination file.

Tests

  • pnpm --filter @cofhe/sdk test -- node/test/storage.test.ts — passes
  • git diff --check — passes

The full SDK test run is currently blocked locally by the existing @cofhe/test-setup package-entry resolution issue, unrelated to these changes.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5e5fb62

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/sdk Patch
@cofhe/abi Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/react Patch
@cofhe/site Patch
@cofhe/example-react Patch
@cofhe/foundry-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@pekkahcut is attempting to deploy a commit to the Fhenix Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to 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.

1 participant