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

Excessive invalidation in ArrowFunctionExpression #2873

Closed
Conduitry opened this issue May 26, 2019 · 3 comments
Closed

Excessive invalidation in ArrowFunctionExpression #2873

Conduitry opened this issue May 26, 2019 · 3 comments
Labels

Comments

@Conduitry
Copy link
Member

<script>
	let url
	let resp;
	$: fetch(url).then(r => resp = r);
</script>

With something like this, the compiler produces

	$$self.$$.update = ($$dirty = { url: 1 }) => {
		if ($$dirty.url) { fetch(url).then(r => { const $$result = resp = r; $$invalidate('resp', resp), $$invalidate('url', url); return $$result; }); }
	};

There doesn't seem to be any reason for url to be invalidated here, and it causes an infinite loop. Using $: fetch(url).then(r => { resp = r; }); instead invalidates only resp as expected.

@Conduitry Conduitry added the bug label May 26, 2019
@Conduitry
Copy link
Member Author

I think this is the result of the change in #2694. The return that happens here only when we pass a value is confusing me. I don't know why that's the only case we want to skip the recursive invalidation. I'm not actually sure what it means to pass or not pass that second argument to invalidate. If we here instead call it with component.invalidate(name, name), that seems to address this particular issue, but I have no idea what the other implications of this are. It doesn't appear to break any existing tests. Nor does doing that a few lines lower in the /Statement/ branch.

@Conduitry
Copy link
Member Author

This is a duplicate of #2748 I think.

@Conduitry
Copy link
Member Author

Fixed in 3.10.1.

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

No branches or pull requests

1 participant