Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug that was causing record.send() and record.update() issues #300

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

frankhinek
Copy link
Contributor

@frankhinek frankhinek commented Nov 20, 2023

Summary

This is primarily a bug fix PR that resolves an issue that was causing dateModified to never be updated after executing record.update() and intermittently caused record.send() to fail after one or more record.update() operations.

Context

Several months ago dwn-sdk-js PR #419 changed and standardized the naming convention for timestamps across all interfaces. At the time, the decision was made to retain the dateCreated and dateModified property names for the Record model used in @web5/api. Since Record is a logical representation of a record, dateCreated maps to the timestamp when the initial RecordsWrite was created and dateModified maps to the timestamp of the most recent modification.

Unfortunately, when @web5/api was updated to reflect this change an update to the list of mutable properties was missed, which resulted in a bug:

  • After each record.update() operation, the messageTimestamp descriptor property was not updated. As a result, subsequent updates would be written with the same messageTimestamp.

Changes

@web5/api

  • Fix bug so that a Record instance's messageTimestamp property is updated each time a modification is made.
  • Add tests to confirm that this resolves both the issue of repeated record.update() operations not updating the timestamp and to ensure that record.send() succeeded in writing to the remote DWN after multiple rounds of update()/send().

@frankhinek frankhinek added the bug Something isn't working label Nov 20, 2023
@frankhinek frankhinek added this to the @web5/api 0.8.3 milestone Nov 20, 2023
@frankhinek frankhinek self-assigned this Nov 20, 2023
Copy link

codesandbox bot commented Nov 20, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

TBDocs Report

✅ No errors or warnings

@web5/api

  • Project entry file: packages/api/src/index.ts

Updated @ 2023-11-20T01:29:57.828Z - Commit: 7b5e27b

Copy link
Contributor

@mistermoe mistermoe left a comment

Choose a reason for hiding this comment

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

nice. easy enough!

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #300 (8104b02) into main (d57927a) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #300   +/-   ##
=======================================
  Coverage   90.80%   90.80%           
=======================================
  Files          74       74           
  Lines       14072    14072           
  Branches     1387     1387           
=======================================
  Hits        12778    12778           
  Misses       1269     1269           
  Partials       25       25           
Components Coverage Δ
api 96.68% <100.00%> (ø)
common 95.00% <ø> (ø)
credentials 94.49% <ø> (ø)
crypto 100.00% <ø> (ø)
dids 88.75% <ø> (ø)
agent 88.07% <ø> (ø)
identity-agent 56.81% <ø> (ø)
proxy-agent 58.43% <ø> (ø)
user-agent 55.22% <ø> (ø)

@frankhinek frankhinek merged commit 3c62a78 into main Nov 20, 2023
27 of 28 checks passed
@frankhinek frankhinek deleted the fix-record-update branch November 20, 2023 14:19
finn-block pushed a commit that referenced this pull request Mar 19, 2024
finn-block pushed a commit that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants