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

Conversation

lukester1975
Copy link
Contributor

I don't think it should rely on changeHandler being invoked to clear the cache.

@tristan957
Copy link
Contributor

Could you explain the problem this fixes?

@@ -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.

@xclaesse
Copy link
Member

@lukester1975 if it fails, what hope so you have that it will succeed next time? I think only a reconfigure has a chance to fix the error potentially.

@lukester1975
Copy link
Contributor Author

Yeah, this is mainly about UX. Caching a failed getMesonTasks means further attempts to run a task do nothing, no showErrorMessage dialog etc.

But also reasoning about whether changeHandler is going to fire in every case that might "fix" the failure is too difficult (impossible?). Simpler to just not cache on failure.

Thanks

@tristan957
Copy link
Contributor

@xclaesse should we just merge this and spin a release?

@xclaesse
Copy link
Member

@tristan957 TBH I was not convinced about this PR, if getting tasks failed once, it won't magically succeed next time. The only thing this could achieve is slowing down everything (load tasks is slow) and spamming user with the error message. Unless I missed something?

AFAIK, the only chance we have to have loading tasks succeed again is after a reconfigure, in that case we do that already.

@lukester1975
Copy link
Contributor Author

Maybe I was unclear so let me try again: it's not about magically succeeding next time. It's about the lack of any feedback running tasks after caching the failure.

Not caching the failed result was the smallest mod I could see to achieve this. Such feedback is not spam... spam is unsolicited.

Worrying about "slowing down everything" isn't an issue for the super rare case of getMesonTasks failing.

@tristan957
Copy link
Contributor

Seems pretty compelling to me after that explanation.

@xclaesse
Copy link
Member

I should give it a try to see how it goes in practice. I'm in phone ATM, can't test until Monday.

The reason I'm prudent here is because when I implemented that cache it was because vscode calls that method a lot to populate menus, and parsing interpretation JSON files is super slow. So I would like to be sure it shows error only when user really does an action and not spuriously just because vscode refresh a menu.

Maybe it should cache the error state to not retry parsing and show error immediately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants