Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't cache failed getMesonTasks() result. #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ export async function activate(ctx: vscode.ExtensionContext) {
controller.createRunProfile("Meson run test", vscode.TestRunProfileKind.Run, (request, token) => testRunHandler(controller, request, token), true)
ctx.subscriptions.push(controller);

let mesonTasks: Thenable<vscode.Task[]> | null = null;
let mesonTasks: Promise<vscode.Task[]> | null = null;
Copy link
Member

Choose a reason for hiding this comment

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

OOC what does that do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no catch() on a Thenable.

ctx.subscriptions.push(
vscode.tasks.registerTaskProvider("meson", {
provideTasks() {
mesonTasks ??= getMesonTasks(buildDir);
if (mesonTasks == null) {
mesonTasks = getMesonTasks(buildDir);
mesonTasks.catch(() => mesonTasks = null);
}

return mesonTasks;
},
resolveTask() {
Expand Down
2 changes: 1 addition & 1 deletion src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export async function getMesonTasks(buildDir: string) {
"Could not fetch targets. See Meson Build output tab for more info."
);

return [];
throw e;
}
}

Expand Down