fix: 修复内存限流存储异步签名
This commit is contained in:
1 parent
a1b29cedee
commit
d923b8cea9
2 files changed
+5
-8
No files matched your search
@@ -24,19 +24,16 @@ export class MemoryClientErrorThrottleStore implements ClientErrorThrottleStore
|
||||
private readonly recentErrorIds = new Map<string, number>();
|
||||
private readonly windows = new Map<string, number[]>();
|
||||
|
||||
async record(
|
||||
report: ClientErrorThrottleReport,
|
||||
now = Date.now(),
|
||||
): Promise<ClientErrorThrottleResult> {
|
||||
record(report: ClientErrorThrottleReport, now = Date.now()): Promise<ClientErrorThrottleResult> {
|
||||
this.prune(now);
|
||||
|
||||
const dedupeKey = `${report.subject}:${report.errorId}`;
|
||||
if (this.recentErrorIds.has(dedupeKey)) return { duplicate: true };
|
||||
if (this.recentErrorIds.has(dedupeKey)) return Promise.resolve({ duplicate: true });
|
||||
|
||||
this.assertWithinRate(report.subject, now);
|
||||
this.recentErrorIds.set(dedupeKey, now);
|
||||
this.trimDedupe();
|
||||
return { duplicate: false };
|
||||
return Promise.resolve({ duplicate: false });
|
||||
}
|
||||
|
||||
private assertWithinRate(subject: string, now: number): void {
|
||||
|
||||
Reference in new issue
Block a user