Skip to content

Add type as Node | undefined to head #674

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

Merged
merged 11 commits into from
Jun 4, 2025
Merged

Conversation

nishan-singh
Copy link
Contributor

I removed duplicated node source version check in needToRecompute func and make the head's type Node | undefined in cleanUpSources func.

Copy link

changeset-bot bot commented May 3, 2025

⚠️ No Changeset found

Latest commit: d5a6f59

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented May 3, 2025

Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit d5a6f59
🔍 Latest deploy log https://app.netlify.com/projects/preact-signals-demo/deploys/6840a08c1817260008bcaa6d
😎 Deploy Preview https://deploy-preview-674--preact-signals-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nishan-singh nishan-singh changed the title Remove duplicate node version check and add type as Node | undefined for head Remove duplicate node version check and add type as Node | undefined to head May 3, 2025
@JoviDeCroock
Copy link
Member

Your PR needs a changeset

@rschristian rschristian linked an issue May 3, 2025 that may be closed by this pull request
@nishan-singh
Copy link
Contributor Author

I added a changeset. I hope I did it right. I'm really sorry if I messed it up. I have never contributed to open source before.

rschristian
rschristian previously approved these changes May 10, 2025
@rschristian
Copy link
Member

Sorry for the delay here, been quite busy.

It looks like this change isn't quite as innocent as it appears, judging by the state of the CI. ._refresh() will need to be called prior to the check of ._version if the version matches, which this PR breaks.

We might be able to get away with removing the first check instead, though that might hurt benchmarks a bit. Would need to take a deeper look into that.

@rschristian rschristian dismissed their stale review May 17, 2025 06:26

PR breaks multiple test cases

@nishan-singh
Copy link
Contributor Author

Now it calls _refesh() before checking the _version. I ran the tests locally and they seem to pass.

Here is a screenshot:
Screenshot_26-May_13-43-14_16876

@jviide
Copy link
Contributor

jviide commented May 30, 2025

The check is not redundant. The first node._source._version !== node._version checks whether the node._source's value has definitely changed since the node._version was last set. If so, we can skip the node._refresh() check. The second node._source._version !== node._version checks whether node._source's version has changed after the refresh.

This is what the comment "If there's a new version of the dependency before or after refreshing" above the code alludes to.

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^What @jviide said. It's a performance optimization.

@jviide
Copy link
Contributor

jviide commented May 30, 2025

Tried to address the ambiguousness of the code in #690. Thank you @nishan-singh for pointing this out 👍

@rschristian rschristian changed the title Remove duplicate node version check and add type as Node | undefined to head Add type as Node | undefined to head Jun 4, 2025
@rschristian rschristian merged commit 7067c39 into preactjs:main Jun 4, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redundant condition in version check logic
5 participants