Bug 2046434 - Dependency Tree: Hide Resolved doesn’t update Max Depth control#2643
Conversation
dklawren
left a comment
There was a problem hiding this comment.
updateControls() can crash when a tree update fails
In onAction(), we always call updateControls() right after await updateTrees(...), regardless of whether the fetch succeeded:
this.disableControls();
await this.updateTrees({ maxDepth, hideResolved });
this.updateControls({ maxDepth, hideResolved });
When updateTrees() hits its error path — a network failure or a non-2xx response — it calls showErrorMessage(), which runs with clearContainer: true and does this.$container.innerHTML = ''. That wipes out the tag along with the rest of the container.
Then updateControls() runs and does:
this.realDepth = Number(this.$trees.querySelector('meta[name="real-depth"]').content);
Since the meta tag is gone, querySelector(...) returns null and reading .content throws a TypeError. The user sees the "Failed to load" message, but the toolbar is left fully disabled (because disableControls() already ran and the exception prevents it from being re-enabled), so the widget is stuck and an error is logged to the console.
To reproduce: click any toolbar control while the server is returning an error (e.g. a 500 or a dropped connection).
Suggested fix: guard the meta lookup so a missing tag doesn't crash — e.g. only update realDepth when the meta tag is present, and/or skip updateControls() when the update failed so the controls get re-enabled instead of staying disabled.
Bug 2046434 - Dependency Tree: Hide Resolved doesn’t update Max Depth control
Make sure the depth control gets updated properly when clicking on the Show/Hide Resolved button or editing the max depth manually using the number input.