Skip to content

Commit c6d8f64

Browse files
authored
fix: prevent lifecycle_double_unmount warning in REPL (#1288)
* fix: prevent lifecycle_double_unmount warning * prevent warning after error in a module --------- Co-authored-by: 7nik <[email protected]>
1 parent 31d923d commit c6d8f64

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/repl/src/lib/Output/Viewer.svelte

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,17 @@
193193
return untrack(() => original[method].apply(this, v));
194194
}
195195
}
196-
const component = mount(App, { target: document.body });
197-
window.__unmount_previous = () => {
198-
for (const method of console_methods) {
199-
console[method] = original[method];
196+
let component;
197+
try {
198+
component = mount(App, { target: document.body });
199+
} finally {
200+
window.__unmount_previous = () => {
201+
for (const method of console_methods) {
202+
console[method] = original[method];
203+
}
204+
if (component) unmount(component);
205+
window.__unmount_previous = null;
200206
}
201-
unmount(component);
202207
}
203208
}
204209
//# sourceURL=playground:output

0 commit comments

Comments
 (0)