Description
I've started seeing intermittent failures in some of my code-lens tests like "command doesn't exist on undefined".
I added some debug logging, and have discovered that sometimes the results from vscode.executeCodeLensProvider
contain only a range
and no other confirmation.
Here's what my test code looks like:
const cls = await (vs.commands.executeCommand("vscode.executeCodeLensProvider", document.uri, 50) as Thenable<vs.CodeLens[]>);
// TEMP DEBUG
for (const cl of cls) {
if (!cl.command) {
throw new Error(`Got code lens without a command! ${JSON.stringify(cl)}`);
}
}
And it's printing this sometimes:
Error: Got code lens without a command! {"range":[{"line":3,"character":2},{"line":18,"character":4}]}
The ranges match up with what I expect from the provider (and I get the expected count), but there's no way my provider can return ranges without commands - the code looks like this:
return [
new CodeLens(
toRange(document, test.offset, test.length),
{
arguments: [test],
command: "_dart.startWithoutDebuggingTestFromOutline",
title: "Run",
},
),
new CodeLens(
toRange(document, test.offset, test.length),
{
arguments: [test],
command: "_dart.startDebuggingTestFromOutline",
title: "Debug",
},
),
].concat(runTestTemplates.map((t) => new CodeLens(
toRange(document, test.offset, test.length),
{
arguments: [test, t],
command: t.template === "run-test" ? "_dart.startWithoutDebuggingTestFromOutline" : "_dart.startDebuggingTestFromOutline",
title: t.name,
},
)));
It's not consistent - these results show it failed for 1 of 4 tests on macOS, but passed on Windows and Linux:
I've run the tests repeatedly locally but cannot reproduce (it's on Travis where I see it mostly). It feels like a race condition, but I can't figure out why. I don't use resolve
, but I tried passing 50 for the number of items to resolve, but it hasn't helped.