fix: added safety checks for buildgraph functions and revert upgrades (#7215)

This commit is contained in:
SagarRajput-7 2025-03-05 11:13:51 +05:30 committed by GitHub
parent 2f3cee814e
commit 52693eb53e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 8 deletions

View File

@ -250,10 +250,6 @@
"body-parser": "1.20.3",
"http-proxy-middleware": "3.0.3",
"cross-spawn": "7.0.5",
"cookie": "^0.7.1",
"react-router/path-to-regexp": "^1.7.0",
"webpack-dev-server/path-to-regexp": "^1.7.0",
"express/path-to-regexp": "^1.7.0",
"@types/webpack-dev-server/path-to-regexp": "^1.7.0"
"cookie": "^0.7.1"
}
}

View File

@ -106,7 +106,7 @@ export const buildDependencyGraph = (
Object.keys(dependencies).forEach((node) => {
if (!inDegree[node]) inDegree[node] = 0;
if (!adjList[node]) adjList[node] = [];
dependencies[node].forEach((child) => {
dependencies[node]?.forEach((child) => {
if (!inDegree[child]) inDegree[child] = 0;
inDegree[child]++;
adjList[node].push(child);
@ -126,13 +126,13 @@ export const buildDependencyGraph = (
}
topologicalOrder.push(current);
adjList[current].forEach((neighbor) => {
adjList[current]?.forEach((neighbor) => {
inDegree[neighbor]--;
if (inDegree[neighbor] === 0) queue.push(neighbor);
});
}
if (topologicalOrder.length !== Object.keys(dependencies).length) {
if (topologicalOrder.length !== Object.keys(dependencies)?.length) {
console.error('Cycle detected in the dependency graph!');
}