Ensures we clean missing local storage comfy UserId (#3289)

This commit is contained in:
Laurent Erignoux
2025-04-02 10:42:00 +08:00
committed by GitHub
parent 733d71aaac
commit ccb71bf1a3
2 changed files with 23 additions and 3 deletions

View File

@@ -79,6 +79,8 @@ interface ApiMessage<T extends keyof ApiCalls> {
data: ApiCalls[T]
}
export class UnauthorizedError extends Error {}
/** Ensures workers get a fair shake. */
type Unionize<T> = T[keyof T]
@@ -732,7 +734,12 @@ export class ComfyApi extends EventTarget {
* @returns { Promise<string, unknown> } A dictionary of id -> value
*/
async getSettings(): Promise<Settings> {
return (await this.fetchApi('/settings')).json()
const resp = await this.fetchApi('/settings')
if (resp.status == 401) {
throw new UnauthorizedError(resp.statusText)
}
return await resp.json()
}
/**