leptos icon indicating copy to clipboard operation
leptos copied to clipboard

Hard to Debug NodeRef Warning

Open soundprojects opened this issue 1 year ago • 2 comments

Describe the bug When getting the warning: [Warning] You are setting a NodeRef that has already been filled. It’s possible this is intentional, but it’s also possible that you’re accidentally using the same NodeRef for multiple _ref attributes.

There is no stack trace or way to debug where this warning originates, which NodeRef has already been filled and where to look for it

Leptos Dependencies

leptos = { version = "0.6.9", features = ["csr"] }
leptos_meta = { version = "0.6.9", features = ["csr"] }
leptos_router = { version = "0.6.9", features = ["csr"] }

To Reproduce Steps to reproduce the behavior:

  1. That's the issue, I don't know how to reproduce this

Expected behavior A stack trace or more information of any kind would really help

Screenshots

Additional context

soundprojects avatar Mar 08 '24 14:03 soundprojects

The solution here would be to do what we do for other signals and add a debug-mode-only defined_at: &'static Location<'static> to NodeRef, with #[track_caller] on the functions that allow you to create node refs, so that it can log "You are setting a NodeRef, defined at {defined_at}...` instead. It is not likely I will get to this in the near future but would welcome a PR from anyone.

gbj avatar Mar 18 '24 15:03 gbj

I think that PR above is a good reponse to the problem.

martinfrances107 avatar Mar 25 '24 13:03 martinfrances107