Skip to content

fix[gen1][react]: ENG-8739 change to makeFn() for handling errors when serialising functions #4050

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

clyde-builderio
Copy link
Contributor

@clyde-builderio clyde-builderio commented Apr 30, 2025

Description

Changed makeFn() for handling errors when serialising functions

JIRA Ticket
https://builder-io.atlassian.net/browse/ENG-8739

PR that caused the hydration error
#3396

Steps to reproduce
See this comment - https://builder-io.atlassian.net/browse/ENG-8739?focusedCommentId=28667

Loom
https://www.loom.com/share/8b961a80726d4fe4ad8bdf52e389f72a

Screenshot

Before After
Screenshot 2025-04-30 at 11 19 52 AM Screenshot 2025-04-30 at 11 19 14 AM

Code coverage
Screenshot 2025-05-01 at 7 43 23 AM

Copy link

changeset-bot bot commented Apr 30, 2025

⚠️ No Changeset found

Latest commit: e488305

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

nx-cloud bot commented Apr 30, 2025

View your CI Pipeline Execution ↗ for commit e488305.

Command Status Duration Result
nx test @e2e/qwik-city ✅ Succeeded 10m 8s View ↗
nx test @e2e/sveltekit ✅ Succeeded 5m 56s View ↗
nx test @e2e/vue ✅ Succeeded 4m 52s View ↗
nx test @e2e/svelte ✅ Succeeded 4m 52s View ↗
nx test @e2e/solid-start ✅ Succeeded 4m 42s View ↗
nx test @e2e/nuxt ✅ Succeeded 7m 59s View ↗
nx test @e2e/remix ✅ Succeeded 5m 5s View ↗
nx test @e2e/solid ✅ Succeeded 4m 36s View ↗
Additional runs (38) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-05-29 06:04:43 UTC

Copy link

gitguardian bot commented May 1, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
11707119 Triggered Generic High Entropy Secret e488305 packages/sdks/snippets/react-sdk-next-14-app/app/(blueprints-product-details)/home/page.tsx View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@clyde-builderio clyde-builderio marked this pull request as ready for review May 1, 2025 08:04
Comment on lines +215 to +220
try {
return JSON.parse(stringify(val));
} catch (e) {
log('Error:', e);
return refToProxy(val);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

i will let @teleaziz or @samijaber review this PR. I am not fully grasping this change, I am thinking if instead of a try catch we should handle passing of functions correctly. I can see that here we return the value itself if the obj is not an object:

if (typeof obj !== 'object' || obj === null) {
return obj;
}

and I am guessing that's fixing this issue because we're re-calling it to handle this? and I can see some error logs that you're printing in the server in your loom that fn couldn't get parsed.

What if we check if the value (const val = obj.getSync(key);) is not an object then just return it without parsing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-05-02 at 4 05 53 PM

Tried this. I am getting hydration-error
typeof val will always be object as val is a Reference

Screenshot 2025-05-02 at 4 05 37 PM

Copy link
Contributor

@samijaber samijaber left a comment

Choose a reason for hiding this comment

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

LGTM, but its missing a changeset

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.

4 participants