Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,32 @@ export class ConnectionFormOriginInfoFormPart extends FormPart<IConnectionFormOr
this.formState.formStateTask.addHandler(this.formAuthState.bind(this));
}

private async formAuthState(data: IConnectionFormState, contexts: IExecutionContextProvider<IConnectionFormState>) {
private authStateTask?: Promise<void>;
private authStateTaskKey?: string;

// formAuthState can be called multiple times by the form flow,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please return to these fixes once we have stable steps to reproduce the issue.

// which triggers multiple calls to resources and triggers "execution queue limit reached" error
// probably the core issue is in the resource and we need to wait to release the loader there,
// but we need more cases to say so
private formAuthState(data: IConnectionFormState, contexts: IExecutionContextProvider<IConnectionFormState>): Promise<void> {
const connectionKey = this.optionsPart.connectionKey;
const taskKey = `${connectionKey?.projectId ?? ''}:${connectionKey?.connectionId ?? ''}:${this.optionsPart.state.driverId ?? ''}`;

if (this.authStateTask && this.authStateTaskKey === taskKey) {
return this.authStateTask;
}

const task = this.loadAuthState(contexts);
this.authStateTask = task;
this.authStateTaskKey = taskKey;
task.then(
() => this.clearAuthStateTask(task),
() => this.clearAuthStateTask(task),
);
return task;
}

private async loadAuthState(contexts: IExecutionContextProvider<IConnectionFormState>): Promise<void> {
const stateContext = contexts.getContext(formStateContext);

const info = this.optionsPart.connectionKey ? await this.connectionInfoAuthPropertiesResource.load(this.optionsPart.connectionKey) : null;
Expand All @@ -51,6 +76,13 @@ export class ConnectionFormOriginInfoFormPart extends FormPart<IConnectionFormOr
}
}

private clearAuthStateTask(task: Promise<void>): void {
if (this.authStateTask === task) {
this.authStateTask = undefined;
this.authStateTaskKey = undefined;
}
}

protected override async loader(): Promise<void> {}

protected override async saveChanges(): Promise<void> {}
Expand Down
Loading