Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: load persisted Runway catalog before paid submission checks

[._.]/ Adam Eivya911ca9d9d9d
diff --git a/server/services/runwayApi.js b/server/services/runwayApi.js
index e7c9c71e89..8508dbb91e 100644
--- a/server/services/runwayApi.js
+++ b/server/services/runwayApi.js
@@ -110,7 +110,7 @@ export async function cancelRunwayTask(entry) {
/** Submit one paid generation to a generation endpoint. Resolves to the task id. */
export async function submitRunwayTask({ apiKey, endpoint, body }) {
- assertRunwayCatalogModel(endpoint, body.model);
+ await assertRunwayCatalogModel(endpoint, body.model);
const res = await fetchWithTimeout(`${RUNWAY_API_BASE}/v1/${endpoint}`, {
method: 'POST', headers: headers(apiKey, true), body: JSON.stringify(body),
}, RUNWAY_SUBMIT_TIMEOUT_MS).catch((err) => {
diff --git a/server/services/runwayModelCatalog.js b/server/services/runwayModelCatalog.js
index b454d56249..86a786a176 100644
--- a/server/services/runwayModelCatalog.js
+++ b/server/services/runwayModelCatalog.js
@@ -111,6 +111,8 @@ export function _createRunwayModelCatalog({
}
return {
current: present,
+ /** Loads the persisted cache only; never fetches documentation. */
+ ready: read,
async get({ refresh: force = false } = {}) {
if (pending) {
if (force && !pendingForced) return pending.then(() => this.get({ refresh: true }));
@@ -130,7 +132,8 @@ const catalog = _createRunwayModelCatalog();
export const getRunwayModelCatalog = (options) => catalog.get(options);
/** Refreshed removals/schema changes fail before a paid submission. No catalog lookup per render. */
-export function assertRunwayCatalogModel(endpoint, modelId) {
+export async function assertRunwayCatalogModel(endpoint, modelId) {
+ await catalog.ready(); // a restart must not submit from the bundled list before the persisted refresh loads
const current = catalog.current();
if (current.available[endpoint] && !current.available[endpoint].includes(modelId)) {
throw Object.assign(new Error(`Runway ${modelId} is unavailable for ${endpoint}; refresh the model catalog or choose another model`), { status: 400, code: 'RUNWAY_MODEL_UNAVAILABLE' });
diff --git a/server/services/runwayModelCatalog.test.js b/server/services/runwayModelCatalog.test.js
index 4d66280b97..e5daf0d5d6 100644
--- a/server/services/runwayModelCatalog.test.js
+++ b/server/services/runwayModelCatalog.test.js
@@ -88,4 +88,14 @@ describe('Runway public catalog cache', () => {
expect(updated.available.character_performance).toEqual([]);
expect(updated.unsupported.map((r) => r.id)).toEqual(expect.arrayContaining(['gen4_image', 'future_image']));
});
+
+ it("loads the persisted catalog before a submission check without fetching documentation", async () => {
+ const { cache, options, fetchSchema } = await setup();
+ await cache.get();
+ const restarted = _createRunwayModelCatalog(options);
+ expect(restarted.current().bundled).toBe(true);
+ await restarted.ready();
+ expect(restarted.current()).toMatchObject({ bundled: false });
+ expect(fetchSchema).toHaveBeenCalledTimes(1);
+ });
});