HumanSignal / HumanSignal/label-studio
Label Studio Editor not destroying cleanly
- Dominant language
- TypeScript
- Stars
- 28.3k
- Forks
- 3.7k
- Avg merge
- 14h
- Merged PRs (30d)
- 15
Description
**Describe the bug**
`LabelStudio.destroyAll` or `instance.destroy` function of Label studio frontend editor is not destroying properly which is causing problems when trying to render app again in angular app.
**To Reproduce**
Steps to reproduce the behavior:
1. In an angular app load the script dynamically when the component is to be used.
2. After window.LabelStudio is available, create a new instance of label studio binded to div with any id and save it in component property say labelStudioInstance. The editor will show up.
4. Now in ngOnDestroy call window.LabelStudio.destroyAll or this.labelStudioInstance.destroy()
5. Now go to some other component so ngOnDestroy is called and come back to the same component that shows label studio editor.
Now the console will show below errors and not render the editor.
```
zone.js:1155 Uncaught
Error: MobX Provider: The set of provided stores has changed. See: https://github.com/mobxjs/mobx-react#the-set-of-provided-stores-has-changed-error.
at Provider (main.js:113378:13)
at renderWithHooks (main.js:196256:18)
at updateFunctionComponent (main.js:198627:20)
at beginWork (main.js:200334:16)
at HTMLUnknownElement.callCallback (main.js:185216:14)
at _ZoneDelegate.invokeTask (zone.js:398:33)
at ZoneImpl.runTask (zone.js:158:47)
at ZoneTask.invokeTask [as invoke] (zone.js:479:34)
at invokeTask (zone.js:1105:18)
at globalCallback (zone.js:1136:29)
```
```
The above error occurred in the component:
at Provider (http://localhost:4200/assets/main.js:113366:24)
at div
at http://localhost:4200/assets/main.js:303159:5
at App (http://localhost:4200/assets/main.js:259151:5)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
```
**Expected behavior**
After coming back to the component, the editor should render and the MobxProvider error should not come up.
**Environment (please complete the following information):**
- OS: macOS
- Label Studio Version 1.12.1
Contributor guide
Assessment
This issue has not been assessed yet.