Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{@debug object} doesn't fire when object.property changes #13687

Closed
Rich-Harris opened this issue Oct 19, 2024 · 7 comments · Fixed by #13690
Closed

{@debug object} doesn't fire when object.property changes #13687

Rich-Harris opened this issue Oct 19, 2024 · 7 comments · Fixed by #13690
Milestone

Comments

@Rich-Harris
Copy link
Member

Rich-Harris commented Oct 19, 2024

Describe the bug

Noticed this while updating the tutorial. This is a breaking change from 4 and makes @debug a bit useless, though I'm not sure if we should fix it or treat it as deprecated

Reproduction

link

@adiguba
Copy link
Contributor

adiguba commented Oct 19, 2024

The debug message is also useless since it only displays 'Proxy'...

I think it could be fixed easily by using $.snapshot() on all the variables in console.log().
It may be useless in some cases, but for debugging it is not really annoying I think...

@7nik
Copy link

7nik commented Oct 19, 2024

Does @debug has any advantages over $inspect?

@brunnerh
Copy link
Member

  • Does not cause two logs on every change
  • Adds a breakpoint via debugger

@7nik
Copy link

7nik commented Oct 19, 2024

  1. Looking at all those $inpect problems due to being sync, would it make sense to add $inspect.lazy?
  2. You can do
$inspect(foo).with((...args) => {
  console.log(...args);
  debugger;
});

@dummdidumm
Copy link
Member

It's not a breaking change per se, because it will work when state is updated as a whole. The question is whether or not @debug should behave like $inspect (i.e. also fire on any changes within), or only when the variable itself is reassigned. I now slightly lean towards aligning the behavior (did lean the other way at first).

@dummdidumm dummdidumm added this to the 5.x milestone Oct 21, 2024
@adiguba
Copy link
Contributor

adiguba commented Oct 21, 2024

In Svelte 4 @debug already fire on any changes within the object... but of course it's limited by the Svelte 4 model and source-analysis.

Example : https://svelte.dev/repl/8248f009ac7946f9840fa6103f7d2568?version=4.2.19

This is a debugging tool, it should be as responsive as possible IMHO.
(and eventually deprecated for the benefit of $inspect)

@Rich-Harris
Copy link
Member Author

yeah i think snapshotting is probably the right approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants