1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: EventStore#getMaxRevisionId can return null (#4384)

In a new fresh Unleash instance with cache enabled this can cause
feature toggles to never get updated.

We saw in our client that the ETag was ETag: "60e35fba:null" Which
looked incorrect for us.

I also did manual testing and if the andWhere had a value of largerThan
higher than whatever the id was then we would get back { max: null }.

This should fix that issue.
This commit is contained in:
Arne-Christian Rundereim 2023-08-01 23:59:09 +02:00 committed by GitHub
parent 5b35e6f877
commit 8aec4a02cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -162,7 +162,7 @@ class EventStore implements IEventStore {
) )
.andWhere('id', '>=', largerThan) .andWhere('id', '>=', largerThan)
.first(); .first();
return row ? row.max : -1; return row?.max ?? 0;
} }
async delete(key: number): Promise<void> { async delete(key: number): Promise<void> {

View File

@ -18,10 +18,11 @@ export default class ConfigurationRevisionService extends EventEmitter {
super(); super();
this.logger = getLogger('configuration-revision-service.ts'); this.logger = getLogger('configuration-revision-service.ts');
this.eventStore = eventStore; this.eventStore = eventStore;
this.revisionId = 0;
} }
async getMaxRevisionId(): Promise<number> { async getMaxRevisionId(): Promise<number> {
if (this.revisionId) { if (this.revisionId > 0) {
return this.revisionId; return this.revisionId;
} else { } else {
return this.updateMaxRevisionId(); return this.updateMaxRevisionId();