1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00

fix: prevent duplicate lifecycle timing (#11017)

This commit is contained in:
Mateusz Kwasniewski 2025-11-24 12:43:14 +01:00 committed by GitHub
parent e455426b3c
commit bbad97a9e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -58,14 +58,15 @@ export class FeatureLifecycleStore implements IFeatureLifecycleStore {
stopTimer();
return [];
}
const baseTime = new Date();
const result = await this.db('feature_lifecycles')
.insert(
validStages.map((stage) => ({
validStages.map((stage, index) => ({
feature: stage.feature,
stage: stage.stage,
status: stage.status,
status_value: stage.statusValue,
created_at: new Date(),
created_at: new Date(baseTime.getTime() + index), // prevent identical times for stages in bulk update
})),
)
.returning('*')

View File

@ -38,7 +38,9 @@ beforeAll(async () => {
db.stores,
{
experimental: {
flags: {},
flags: {
optimizeLifecycle: true,
},
},
},
db.rawDatabase,
@ -178,6 +180,9 @@ test('should return lifecycle stages', async () => {
enteredStageAt: expect.any(String),
},
]);
expect(new Date(body[2].enteredStageAt).getTime()).toBeGreaterThan(
new Date(body[1].enteredStageAt).getTime(),
);
await expectFeatureStage('my_feature_a', 'archived');
eventStore.emit(FEATURE_REVIVED, { featureName: 'my_feature_a' });