Skip to content

Commit 6229ac3

Browse files
authored
fix(backend): ULID使用時にnotificationTimelineへのXADDが失敗し続け、通知が約10秒遅延する問題を修正 (#17358)
1 parent 6d9412b commit 6229ac3

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-
88

99
### Server
10-
-
10+
- Fix: ID生成アルゴリズムにULIDを使用している場合に通知が約10秒遅延する問題を修正
1111

1212

1313
## 2026.5.0

packages/backend/src/core/NotificationService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ export class NotificationService implements OnApplicationShutdown {
246246

247247
private toXListId(id: string): string {
248248
const { date, additional } = this.idService.parseFull(id);
249-
return date.toString() + '-' + additional.toString();
249+
// Redis Stream sequenceはunit64制約があるため、収まらない場合は下位64bitを取る
250+
return date.toString() + '-' + BigInt.asUintN(64, additional).toString();
250251
}
251252

252253
@bindThis

packages/backend/test/unit/misc/ulid.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ describe('misc:ulid', () => {
3838
// id[16] = Z
3939
expect(() => parseUlidFull('01KPS7S300ABCDEFZ000000000')).not.toThrow();
4040
});
41+
42+
test('parseUlidFull - additional exceeds uint64 max (all-Z randomness)', () => {
43+
// All 16 random chars = 'Z' (Crockford max) → 80-bit value > uint64 max
44+
const { additional } = parseUlidFull('01ARZ3NDEKZZZZZZZZZZZZZZZZ');
45+
const uint64Max = 2n ** 64n - 1n;
46+
expect(additional > uint64Max).toBe(true);
47+
expect(BigInt.asUintN(64, additional) <= uint64Max).toBe(true);
48+
});
4149
});

0 commit comments

Comments
 (0)