mirror of
https://github.com/Kong/insomnia.git
synced 2026-11-05 20:43:52 -05:00
revert: drop lock-acquire timeout and team-projects fetch timeout
Both were speculative fixes for the "Create project" dialog hang,
based on a lock-contention/slow-network hypothesis later disproven by
CI timing diagnostics (see 36ea5dce6) — the actual bug was
ProjectModal's close effect, now fixed separately.
Keeping them isn't just unnecessary, it's a regression risk: the 15s
lock-acquire timeout would fire against runKonnectOrgMigration
(src/konnect/migrate-konnect-organization.ts), which holds projectLock
for a synchronous loop over every migratable project and can
legitimately run past 15s for accounts with many projects — turning
a previously-fine "wait it out" into a spurious "Timed out waiting for
another project operation to finish" error on project creation.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
36ea5dce63
commit
1c686a5725
3 files changed
+4
-30
No files matched your search
@@ -7,12 +7,11 @@ interface TeamProjects {
|
||||
}[];
|
||||
}
|
||||
|
||||
export const fetchTeamProjects = ({ sessionId, organizationId, timeout }: { sessionId: string; organizationId: string; timeout?: number }) => {
|
||||
export const fetchTeamProjects = ({ sessionId, organizationId }: { sessionId: string; organizationId: string }) => {
|
||||
return fetch<TeamProjects>({
|
||||
method: 'GET',
|
||||
path: `/v1/organizations/${organizationId}/team-projects`,
|
||||
sessionId,
|
||||
timeout,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -67,13 +67,6 @@ export async function getFirstProjectOfOrganization(organizationId: string) {
|
||||
return db.findOne<Project>(type, { parentId: organizationId });
|
||||
}
|
||||
|
||||
// syncProjects() runs this in the background under the same lock that
|
||||
// guards interactive project creation (see `projectLock` in
|
||||
// packages/insomnia/src/common/project.ts), so it must not be allowed to
|
||||
// hold that lock for as long as the default fetch timeout (30s) — that
|
||||
// blocks a user's "Create project" action for far longer than they'd wait.
|
||||
const TEAM_PROJECTS_FETCH_TIMEOUT_MS = 8000;
|
||||
|
||||
export async function getAllTeamProjects(organizationId: string) {
|
||||
const { id: sessionId } = await userSessionService.get();
|
||||
if (!sessionId) {
|
||||
@@ -81,7 +74,7 @@ export async function getAllTeamProjects(organizationId: string) {
|
||||
}
|
||||
|
||||
console.log('[project] Fetching', organizationId);
|
||||
const response = await fetchTeamProjects({ sessionId, organizationId, timeout: TEAM_PROJECTS_FETCH_TIMEOUT_MS });
|
||||
const response = await fetchTeamProjects({ sessionId, organizationId });
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,6 @@ export interface InsomniaFile {
|
||||
};
|
||||
}
|
||||
|
||||
// How long a caller will wait in queue for the lock before giving up. Without
|
||||
// this, a slow or stuck lock holder (e.g. a background project sync) blocks
|
||||
// every other queued operation (e.g. creating a project) indefinitely, with
|
||||
// no error surfaced to the user.
|
||||
const LOCK_ACQUIRE_TIMEOUT_MS = 15_000;
|
||||
|
||||
const lockGenerator = () => {
|
||||
// Simple mutex lock implementation
|
||||
let isLocked = false;
|
||||
@@ -57,20 +51,8 @@ const lockGenerator = () => {
|
||||
}
|
||||
|
||||
// If already locked, wait in queue
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
const index = lockQueue.indexOf(onUnlocked);
|
||||
if (index !== -1) {
|
||||
lockQueue.splice(index, 1);
|
||||
}
|
||||
reject(new Error('Timed out waiting for another project operation to finish. Please try again.'));
|
||||
}, LOCK_ACQUIRE_TIMEOUT_MS);
|
||||
|
||||
const onUnlocked = () => {
|
||||
clearTimeout(timer);
|
||||
resolve();
|
||||
};
|
||||
lockQueue.push(onUnlocked);
|
||||
return new Promise<void>(resolve => {
|
||||
lockQueue.push(resolve);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user