fix(quota): coalesce provider usage refreshes

This commit is contained in:
Bohdan Triapitsyn
2026-08-18 19:13:58 +03:00
parent 84e940a9e4
commit 3326ad0ea8
7 changed files with 267 additions and 39 deletions
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import * as google from './google/index.js';
import { listConfiguredQuotaProviders } from './index.js';
import { fetchQuotaForProvider, listConfiguredQuotaProviders } from './index.js';
describe('quota provider registry', () => {
it('exposes google provider configuration helpers through the provider module', () => {
@@ -14,4 +14,13 @@ describe('quota provider registry', () => {
it('can list configured providers without missing provider exports', () => {
expect(() => listConfiguredQuotaProviders()).not.toThrow();
});
it('coalesces concurrent refreshes by provider ID', async () => {
const first = fetchQuotaForProvider('unsupported-test-provider');
const second = fetchQuotaForProvider('unsupported-test-provider');
expect(first).toBe(second);
await first;
expect(fetchQuotaForProvider('unsupported-test-provider')).not.toBe(first);
});
});