solid icon indicating copy to clipboard operation
solid copied to clipboard

Shouldn't roots be disposed when their scope function throws?

Open AFatNiBBa opened this issue 7 months ago • 3 comments

Describe the bug

When something throws (Directly) inside of a function passed to createRoot(), the root that was being created doesn't get disposed. Is this expected?

Your Example Website or App

https://playground.solidjs.com/anonymous/1e6d765f-717a-4fef-a981-573593533dcc

Steps to Reproduce the Bug or Issue

  1. Go to the playground link
  2. Check the console

Expected behavior

The root should be disposed and "Disposing" should be logged

Screenshots or Videos

No response

Platform

(Irrelevant)

Additional context

No response

AFatNiBBa avatar May 19 '25 14:05 AFatNiBBa

During dev mode, the component could be automatically disposed due to solid-refresh, in that case you need to put

/* @refresh skip */

at the start of your file to reproduce the issue

AFatNiBBa avatar May 19 '25 22:05 AFatNiBBa

It's an interesting question.. Usually it is the parent or some manual mechanism responsible for disposal. That being said if you don't even get access to the dispose then what can anyone expect to do with it. Honestly it never occurred to me to dispose in this case. Top level render dispose call also destroys the DOM nodes. Is that expected? Hmm.. I might need to think about this.

ryansolid avatar Aug 06 '25 21:08 ryansolid

I think it's probably expected that whatever render() did will get reverted by the disposal, even the DOM nodes

AFatNiBBa avatar Aug 11 '25 07:08 AFatNiBBa