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:
parent
5b35e6f877
commit
8aec4a02cb
@ -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> {
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user