Skip to content

Fix local get after publish and cache reliability#4095

Open
Bojan131 wants to merge 1 commit intov8/developfrom
fix/local-get-cache
Open

Fix local get after publish and cache reliability#4095
Bojan131 wants to merge 1 commit intov8/developfrom
fix/local-get-cache

Conversation

@Bojan131
Copy link
Collaborator

What

Fixes the issue where asset.get() would fail immediately after a publish because the data wasn't in the triple store yet but was still in the pending cache.

Changes

Get command cache fallback (get-command.js)

  • When the triple store doesn't have the data yet, the get command now checks the pending storage cache as a fallback
  • Uses the new merkle root index to find the right operationId for cache lookup

Pending storage improvements (pending-storage-service.js)

  • Added a merkle root -> operationId index for fast lookups without scanning the file system
  • Index entries are cleaned up when cached data is removed (prevents memory leak over time)

Publish finalization retries (publish-finalization-command.js)

  • Reading cached assertion data during finalization now retries (5 attempts, 5s apart) instead of failing immediately
  • This handles the race condition where finalization runs before cache write completes

Repository (finality-status-repository.js)

  • Added getPublishOperationIdByUal to look up operation IDs by UAL for cache fallback

Why

After a publish, the data lives in pending cache until blockchain finalization completes. If someone does a get during that window, it should still return the data. Previously it would just fail with a "falsy value" assertion error.

Made with Cursor

- Add pending storage cache fallback in get-command so gets work right after publish
- Add merkle root index in pending-storage-service for fast operationId lookups
- Clean up merkle root index entries on cache removal to prevent memory leak
- Add retry logic in publish-finalization-command for reading cached assertion data
- Reduce cache retry window from 100s to 25s (5 retries x 5s) for faster failure detection
- Add getPublishOperationIdByUal repository method for cache lookups

Made-with: Cursor
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