Repository navigation
Description
Adding or syncing an instrument repository is reported as failed after 10 seconds, while the server carries on and finishes the import. The axios interceptor aborts every request after 10 s unless it opts out with meta.disableDefaultTimeout. useCreateInstrumentRepoMutation and useSyncInstrumentRepoMutation do not opt out. Both endpoints download the repository's zipball from GitHub (the server allows 60 s for that alone) and then run esbuild over every instrument in it. The Add Repository dialog warns "Importing may take a minute", and the sync hook's own comment calls the sync "potentially slow". For any repository with more than a handful of instruments, the browser times out first. The admin sees "Failed to import repository" / "Failed to sync repository", then the error page (#1731). The repository then shows up imported after a reload. A retry of the import is treated by the API as a re-sync, so it times out again the same way.
Where
apps/web/src/hooks/useCreateInstrumentRepoMutation.ts:15-16:
mutationFn: ({ data }: { data: $CreateInstrumentRepoData }) =>
axios.post('/v1/instrument-repos', data, { meta: { disableDefaultErrorNotification: true } }),apps/web/src/hooks/useSyncInstrumentRepoMutation.ts:14-15:
mutationFn: ({ id }: { id: string }) =>
axios.post(`/v1/instrument-repos/${id}/sync`, undefined, { meta: { disableDefaultErrorNotification: true } }),apps/web/src/services/axios.ts:108-109, the default being hit:
if (!config.meta?.disableDefaultTimeout) {
config.timeout = 10000; // abort request after 10 secondsReproduce
- As an admin, open Admin Panel → Instrument Repos → Add Repository.
- Enter a GitHub instrument repository whose import takes longer than 10 s (any repository with a few dozen instruments, or any repository on a slow link to GitHub).
Actual: after 10 s the request is aborted and "Failed to import repository" is shown. Reloading the page shows the repository was imported.
Expected: the client waits for the import to finish, and reports success or the server's actual error.
Tests
apps/web/src/hooks/__tests__/useCreateInstrumentRepoMutation.test.tsanduseSyncInstrumentRepoMutation.test.ts:it('should opt out of the default request timeout, since an import can outlast it'), asserting the request config carriesmeta.disableDefaultTimeout: true.testing/src/specs/admin-instrument-repos.spec.ts: routePOST **/v1/instrument-reposto answer after 12 s, and assert the dialog reports success rather than failure.
Suggested fix
Pass meta: { disableDefaultErrorNotification: true, disableDefaultTimeout: true } on both requests, as useCreateSetupStateMutation does for the similarly slow /v1/setup. Optionally set an explicit timeout a little above the server's 60 s download budget plus bundling time.
Activity
fix(web): stop aborting instrument repository imports after 10 seconds