Skip to content

Update rave-level to be compatible with abstract-level 2.0 API - #13

Open
Eranziel wants to merge 51 commits into
Level:mainfrom
ForgeVTT:main
Open

Eranziel wants to merge 51 commits into
Level:mainfrom
ForgeVTT:main

Conversation

@Eranziel

@Eranziel Eranziel commented Sep 3, 2025

Copy link
Copy Markdown

This PR updates rave-level to conform to the abstract-level 2.0 APIs. It requires Level/many-level#13. Currently it installs our fork of many-level, but of course that should be updated to use the official npm package once it is ready.

In general, this means everything has been converted from callbacks to promises. Unfortunately it does not encompass all of the work required to update rave-level; our use case does not use all of the features of rave-level, so due to limited time and competing priorities I had to forego solving several test failures which do not affect our use case.

A few notable changes:

  • I updated the minimum node version to 16, matching abstract-level 2.0.
  • This branch also includes a couple of bug fixes we implemented on our fork for rave-level 1.0.
  • I have attempted to conform to the prevailing code style, but did add descriptive comments in several places. I hope these aren't an issue, because personally I would have found them quite helpful when gaining an initial understanding of the code base.
  • There are many updates still needed to the test suite. Unfortunately I ran out of time to work on those.

While this isn't a complete update in and of itself, I hope this serves useful on the road to 2.0!

@Eranziel

Eranziel commented Nov 5, 2025

Copy link
Copy Markdown
Author

@vweevers hi there! Just wanted to touch base on this and see if you have any questions for me about this PR, or if there's anything I can do to help move it along? Not trying to be a bother, just checking in!

germanoeich and others added 11 commits June 17, 2026 17:40
Support getSync for rave-level followers, refactor connection flow
…ossible

While the database was still opening, a failed attempt to open the
underlying classic-level database (corruption, IO error, or a lock held
for the whole retry window while nobody answered on the socket) was
handed to kDestroy, which only emits when the status is "open". The
error was dropped, _open() resolved, and the instance was left neither
leader nor follower: every later operation was queued for a leader that
never came and hung forever. Foundry never saw an error and therefore
never ran its database repair.

Throw the underlying classic-level error instead while opening, so that
db.open() rejects with LEVEL_DATABASE_NOT_OPEN and that error as cause,
deferred operations are rejected, and the database ends up closed, the
same way classic-level itself behaves. During failover (status "open")
the error is still emitted as before.

Also start the lock retry window at the beginning of every connection
attempt instead of only the first one, so a failover after a leader
closed does not give up immediately.
…eouts

Review feedback on the previous commit:

The retry window reset was reverted. kConnect is only re-entered after a
follower's connection to a leader closed, and onconnect already clears
the timestamp in that case, so setting it unconditionally at the start
of kConnect changed nothing in practice and was not worth the doubt. The
timeout check keeps its original guard, only inverted to read as "still
within the window".

tape does not time out on its own and the bug under test is a hang, so
every await that would stall on a regression now races a timeout and
fails with a message instead of stalling the suite.
Reject open() when neither a leader connection nor a leader open is possible
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.

5 participants