fix(server): tell a user over the routing allowance when to ask the relay again

The per-user 429 carried no Retry-After, so the planner left the relay alone for
its full ten minutes and routed every day with OSRM meanwhile. It now answers
like the installation limit does, with the minute the window takes.
This commit is contained in:
Maurice
2026-10-29 12:25:50 +01:00
committed by Maurice
parent 7dc313c567
commit e3a8c6fb8a
2 changed files with 13 additions and 6 deletions
@@ -124,12 +124,12 @@ describe('RoutingRelayService.ask', () => {
expect(safeFetchAdminConfigured).not.toHaveBeenCalled();
});
it('RELAY-006: holds every user to 60 questions a minute, each user apart', async () => {
it('RELAY-006: holds every user to 60 questions a minute, each user apart, and says when to come back', async () => {
vi.mocked(safeFetchAdminConfigured).mockImplementation(async () => upstream(200, '{}'));
await oneByOne(times(60), () => relay.ask(1, 'height', { shape: [{ lat: 47, lon: 11 }] }));
const refused = await relay.ask(1, 'route', ROUTE).catch((err: unknown) => err);
expect(refused).toBeInstanceOf(DomainError);
expect(refused).toMatchObject({ status: 429, message: 'Too many routing requests, try again in a minute' });
const refused = await relay.ask(1, 'route', ROUTE);
expect(refused).toMatchObject({ status: 429, retryAfter: '60' });
expect(JSON.parse(refused.body.toString())).toEqual({ error: 'Too many routing requests, try again in a minute' });
expect((await relay.ask(2, 'route', ROUTE)).status).toBe(200);
expect(safeFetchAdminConfigured).toHaveBeenCalledTimes(61);
});