Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Plugin cyclical check ignores optional plugins #389

Closed
vidartf opened this issue Jun 13, 2019 · 0 comments · Fixed by #390
Closed

Plugin cyclical check ignores optional plugins #389

vidartf opened this issue Jun 13, 2019 · 0 comments · Fixed by #390

Comments

@vidartf
Copy link
Contributor

vidartf commented Jun 13, 2019

There was recently an issue on the jupyterlab repo, where a cyclical plugin dependency was reported. The error ended up being reported as a Maximum call stack size exceeded. It turns out that the reason why the phosphor cycle check did not catch it was because one of the parts of the loop was an optional dependency.

Relevant code at time of submission:

function ensureNoCycle(data: IPluginData, pluginMap: PluginMap, serviceMap: ServiceMap): void {
// Bail early if there cannot be a cycle.
if (!data.provides || data.requires.length === 0) {
return;
}
// Setup a stack to trace service resolution.
let trace = [data.id];
// Throw an exception if a cycle is present.
if (data.requires.some(visit)) {
throw new Error(`Cycle detected: ${trace.join(' -> ')}.`);
}
function visit(token: Token<any>): boolean {
if (token === data.provides) {
return true;
}
let id = serviceMap.get(token);
if (!id) {
return false;
}
let other = pluginMap[id];
if (other.requires.length === 0) {
return false;
}
trace.push(id);
if (other.requires.some(visit)) {
return true;
}
trace.pop();
return false;
}
}

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

Successfully merging a pull request may close this issue.

1 participant