Skip to content

Conversation

@iqdoctor
Copy link
Contributor

No description provided.

@punkpeye
Copy link
Owner

Looks like the checks are not passing.

@iqdoctor
Copy link
Contributor Author

iqdoctor commented Nov 16, 2025

pnpm test

 Test Files  6 passed (6)
      Tests  67 passed (67)
   Start at  08:27:15
   Duration  8.92s (transform 519ms, setup 0ms, collect 1.42s, tests 17.62s, environment 1ms, prepare 732ms)

The runner is failing on InMemoryEventStore > stores events and replays them after a specific event ID.

Locally we always get 3 replayed events because each storeEvent() call falls into a different millisecond. On GitHub Actions, multiple events share the same Date.now() value, so the generated eventIds differ only in the random suffix. Since replayEventsAfter() sorts by the eventId string (see src/InMemoryEventStore.ts#41-67), one of the “future” events can end up ordered before the lastEventId, which means it never gets replayed once foundLastEvent flips to true. The test then sees only 2 events.

We need to make ordering deterministic when timestamps collide—e.g. track an incrementing counter/order column or append it to the eventId—so all events after lastEventId always sort after it, even if Date.now() returns the same value. Once we guarantee insertion order, that test will be stable in CI.

@iqdoctor
Copy link
Contributor Author

Should I update the tests, or would you prefer a deterministic ordering fix inside InMemoryEventStore (e.g., monotonic counter appended to the event IDs) so CI never drops an event?

@punkpeye
Copy link
Owner

would you prefer a deterministic ordering fix inside InMemoryEventStore (e.g., monotonic counter appended to the event IDs) so CI never drops an event?

That seems like a more robust approach. I appreciate the contributions!

@punkpeye
Copy link
Owner

Could you please update the tests?

@iqdoctor
Copy link
Contributor Author

iqdoctor commented Nov 22, 2025

Make InMemoryEventStore event IDs monotonic and update tests

  • generate IDs as ${streamId}_${timestamp}_${counter}_${random} with base36 counter + random tail
  • document the new monotonic scheme in InMemoryEventStore
  • adjust deterministic-ordering test to validate timestamp/counter/random segments
  • ensure counter reset is covered when the millisecond tick advances

`${streamId}_${timestamp}_${counter}_${random}` format.
@punkpeye punkpeye merged commit 1d51885 into punkpeye:main Nov 23, 2025
1 check passed
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.

2 participants