🧑‍🏭 fix: Initialize Remote SDK Hosts in Cluster Workers (#18519)

This commit is contained in:
Danny Avila 2026-11-19 13:36:10 -05:00 • committed by GitHub
parent 81c2dac327
commit 6aa1c94cd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -61,6 +61,8 @@ const {
startCodeEnvironmentLifecycleReconciler,
waitForKeyvRedisClient,
createCodeApiUploadRegistry,
createSdkFileHost,
createSdkModelHost,
cacheConfig,
createClusteredFileSweep,
createRequestSanitizer,
@ -545,6 +547,8 @@ if (cluster.isMaster) {
}),
{ priority: 50 },
);
app.locals.sdkFileHost = createSdkFileHost(appConfig?.endpoints?.agents?.sdkHostFiles);
app.locals.sdkModelHost = createSdkModelHost(appConfig?.endpoints?.agents?.sdkHostModels);
initializeFileStorage(appConfig);
initializeGitHubSkillSync(appConfig);
startSkillDeletionSweep(appConfig.skillDeletion);

View file

@ -13,6 +13,21 @@ describe('Experimental server configuration', () => {
expect(listenIndex).toBeLessThan(timeoutConfigIndex);
});
it.each([
['File', 'Files'],
['Model', 'Models'],
])('installs the SDK %s host from base config before serving requests', (host, setting) => {
const configIndex = source.indexOf('await getAppConfig({ baseOnly: true });');
const binding = `app.locals.sdk${host}Host = createSdk${host}Host(appConfig?.endpoints?.agents?.sdkHost${setting});`;
const bindingIndex = source.indexOf(binding);
const listenIndex = source.indexOf('const server = app.listen');
expect(configIndex).toBeGreaterThan(-1);
expect(bindingIndex).toBeGreaterThan(configIndex);
expect(listenIndex).toBeGreaterThan(bindingIndex);
expect(source.indexOf(binding, bindingIndex + 1)).toBe(-1);
});
it('lets each worker drain registered services before cluster shutdown', () => {
const listenIndex = source.indexOf('const server = app.listen');
const gracefulShutdownIndex = source.indexOf('setupGracefulShutdown(server);');