Giter Club home page Giter Club logo

ddes's Introduction

DDES

Event Sourcing for JavaScript/TypeScript

Installation

yarn add @ddes/core @ddes/postgres

Example usage

See example usage

ddes's People

Contributors

ddes-ci avatar dependabot[bot] avatar gudleik avatar krijoh92 avatar semantic-release-bot avatar theodorton avatar trym avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ddes's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Snapshot error prevents aggregate from being loaded

> await MyAggregate.load(key)
TypeError: Cannot convert undefined or null to object
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Job.hydrate (/src/node_modules/@ddes/core/lib/Aggregate.ts:388:54)
    at Function.get snapshotCompatChecksum [as snapshotCompatChecksum] (/src/node_modules/@ddes/core/lib/Aggregate.ts:80:48)
    at Array.map (<anonymous>)
    at components.push.Object.keys.map.eventType (/src/node_modules/@ddes/core/lib/Aggregate.ts:82:28)
    at Function.keys (<anonymous>)

Suggestion: if there are any errors with the snapshot, just log and ignore the error

Clients with out-of-sync clocks might cause chronological keys out of order

Description

At one point it was not possible to commit new events due to version conflicts.
With retryOnVersionConflict() it attempted x amount of times before it gave up.
Using MyAggregate.get('key'), returned version 159 as the latest.

Checking the 'events' table directly showed this for the last 2 commits:

[
  {
    aggregateType: 'MyType',
    aggregateKey: 'myAggregateKey',
    aggregateVersion: 160,
    chronologicalKey: '20240216095823590:MyType:myAggregateKey:160',
    chronologicalPartition: 'default',
    events: [ [Object] ],
    timestamp: 2024-02-16T09:58:23.590Z,
    expiresAt: null
  },
  {
    aggregateType: 'MyType',
    aggregateKey: 'myAggregateKey',
    aggregateVersion: 159,
    chronologicalKey: '20240216095823593:MyType:myAggregateKey:159',
    chronologicalPartition: 'default',
    events: [ [Object] ],
    timestamp: 2024-02-16T09:58:23.593Z,
    expiresAt: null
  }
]

Note the timestamps.
It seems version 160 was committed with a timestamp 3ms before version 159, which caused the chronological key to be out of order.
And every time a new commit happened, it fetched the 'last' one, got 159, attempted version + 1 and failed.

This was most likely caused by different replicas of the same api committing at the same time, but with slightly out-of-sync clocks, and ddes using Date.now() for timestamps, which in turn is used for chronologicalKey.
AggregateRoot.ts#L200

How to reproduce

Commit events, set local clock back a few seconds and commit new events.

Possible sollutions

Use a single source of truth for timestamps, the postgres db perhaps?

Postgres adapter bugs

  • jsonb data is stringified before insert
  • Aggregate.scanInstances always returns []

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.