Repository navigation
fix(tools): invoke tool reset methods on destroy - #3046
Merged
Merged
Conversation
prajexec
requested review from
TatianaFomina,
gohabereg,
ilyamore88 and
neSpecc
as code owners
November 13, 2026 11:38
Member
this sounds ok |
Contributor
There was a problem hiding this comment.
🟢 Approved
No active review issues were identified for the tool-teardown cleanup fix.
No open issues 🎉
What changed in this PR
Fixes tool cleanup during editor teardown by correctly iterating the Map-backed tool collection, allowing registered tools’ reset() methods to run.
Changes:
- Invokes available tools’ reset methods and catches failures, logging them as warnings.
- Adds regression tests for reset invocation and rejected-reset warning handling.
- Documents the teardown fix in the changelog.
| File | Description |
|---|---|
test/cypress/tests/modules/Tools.cy.ts |
Tests reset invocation and warning logging when reset rejects. |
src/components/modules/tools.ts |
Corrects collection iteration and adds reset error handling. |
docs/CHANGELOG.md |
Records the reset invocation and error-handling fix. |
Review effort: Balanced
neSpecc
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bug
In
src/components/modules/tools.ts,Tools.destroy()invokedObject.values(this.available).forEach(...). Sincethis.availableis an instance ofToolsCollection(which extendsMap),Object.values()returns an empty array[]. As a result,tool.reset()was never actually executed on any available tool when destroying the editor instance.Fix
Replaced
Object.values(this.available)withArray.from(this.available.values())so that each tool'sreset()method is properly invoked during destroy.Test
Added a test spec in
test/cypress/tests/modules/Tools.cy.ts(context('.destroy()')) verifying thatreset()is called on registered tools when the module is destroyed.Behavior Note
Because of the bug,
tool.reset()has effectively never run on destroy until now. None of the default built-in tools currently implement areset()method, but third-party tools defining a staticreset()will now have it executed during teardown as originally intended.Open Question for Maintainers
The loop currently runs as:
Because
forEach(async ...)does not await or collect returned promises, if a tool's asyncreset()rejects, it becomes an unhandled promise rejection..catch(...)with a warning log directly in this PR?