1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 22:15:41 +02:00

fix(backend): ULID使用時にnotificationTimelineへのXADDが失敗し続け、通知が約10秒遅延する問題を修正 (#17358)

This commit is contained in:
mq1
2026-05-02 20:23:10 +09:00
committed by GitHub
parent 6d9412b338
commit 6229ac365e
3 changed files with 11 additions and 2 deletions

View File

@@ -246,7 +246,8 @@ export class NotificationService implements OnApplicationShutdown {
private toXListId(id: string): string {
const { date, additional } = this.idService.parseFull(id);
return date.toString() + '-' + additional.toString();
// Redis Stream sequenceはunit64制約があるため、収まらない場合は下位64bitを取る
return date.toString() + '-' + BigInt.asUintN(64, additional).toString();
}
@bindThis

View File

@@ -38,4 +38,12 @@ describe('misc:ulid', () => {
// id[16] = Z
expect(() => parseUlidFull('01KPS7S300ABCDEFZ000000000')).not.toThrow();
});
test('parseUlidFull - additional exceeds uint64 max (all-Z randomness)', () => {
// All 16 random chars = 'Z' (Crockford max) → 80-bit value > uint64 max
const { additional } = parseUlidFull('01ARZ3NDEKZZZZZZZZZZZZZZZZ');
const uint64Max = 2n ** 64n - 1n;
expect(additional > uint64Max).toBe(true);
expect(BigInt.asUintN(64, additional) <= uint64Max).toBe(true);
});
});