Merge branch 'fix/gateway-trpc-batch-path-20260809'

This commit is contained in:
2026-08-09 10:34:35 +00:00
3 changed files with 47 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
export const gatewayFastifyRouterOptions = {
// tRPC joins batched procedure names in a single route parameter. Fastify's
// default limit is 100 characters, which is shorter than normal admin-page
// startup batches such as capabilities + profiles + release state.
maxParamLength: 2_048,
} as const;
+2
View File
@@ -28,6 +28,7 @@ import { RepositoryProfileStatusService } from './lobby/profileStatusService.js'
import { registerAccountIconInternalRoute } from './auth/accountIconInternalRoute.js';
import { installGatewayShutdownController } from './lifecycle/shutdownController.js';
import { RemoteUserIconStore } from './account/remoteUserIconStore.js';
import { gatewayFastifyRouterOptions } from './fastifyOptions.js';
export const createGatewayApiServer = async () => {
const config = resolveGatewayApiConfigFromEnv();
@@ -80,6 +81,7 @@ export const createGatewayApiServer = async () => {
const app = fastify({
logger: true,
routerOptions: gatewayFastifyRouterOptions,
});
await app.register(cors, {
@@ -0,0 +1,39 @@
import fastify from 'fastify';
import { afterEach, describe, expect, it } from 'vitest';
import { gatewayFastifyRouterOptions } from '../src/fastifyOptions.js';
const apps = new Set<ReturnType<typeof fastify>>();
afterEach(async () => {
await Promise.allSettled(Array.from(apps, (app) => app.close()));
apps.clear();
});
describe('Gateway Fastify routing', () => {
it('accepts the admin release page initial tRPC batch path', async () => {
const app = fastify({
logger: false,
routerOptions: gatewayFastifyRouterOptions,
});
apps.add(app);
app.get('/gateway/api/trpc/:path', async (request) => request.params);
const batchPath = [
'admin.capabilities.list',
'admin.profiles.list',
'admin.capabilities.list',
'admin.releases.gatewayState',
'admin.releases.list',
].join(',');
expect(batchPath.length).toBeGreaterThan(100);
const response = await app.inject({
method: 'GET',
url: `/gateway/api/trpc/${batchPath}?batch=1`,
});
expect(response.statusCode).toBe(200);
expect(response.json()).toEqual({ path: batchPath });
});
});