Skip to content

Conversation

@yash-builder
Copy link
Contributor

@yash-builder yash-builder commented Oct 6, 2025

Description

• Detect @Input() content switch (id differs from current)
• Re-initialise builderContextSignal.content & rootState
• Regenerate AB-test visibility script
This ensures repeaters/blocks re-render correctly after SSR refresh and route reuse, eliminating the need for custom RouteReuseStrategy hacks.

  • Also updated to skip blueprints-editorial.spec.ts snippet test for ssr frameworks since the fakestoreapi mocked in this PR doesn't not work for ssr frameworks leading to them being flaky, it works only for csr.

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

Loom
https://www.loom.com/share/47d4f285da2a45f2bd1ff6cc82bdad4c?sid=16e0dad3-3104-4fbf-99fd-7f4b1378695a


Note

Fixes Angular SSR hydration when navigating by resetting content/root state and scripts on content ID change, and updates tests/skip lists; adds patch changeset.

  • Angular SDK:
    • content.lite.tsx: On Angular target, detect props.content.id changes and reinitialize builderContextSignal.content and rootState; regenerate AB-test visibility script.
    • enable-editor.lite.tsx: On Angular target, when content changes, rerun HTTP requests on ID change and merge new content during update.
  • Tests:
    • blueprints-editorial.spec.ts: Expand skipped packages to cover additional SSR frameworks.
    • custom-components.spec.ts: Broaden Angular SSR check/message to include Angular 17 and 19.
  • Release:
    • Changeset: patch for @builder.io/sdk-angular addressing SSR hydration during routing.

Written by Cursor Bugbot for commit 46f284c. This will update automatically on new commits. Configure here.

@yash-builder yash-builder requested a review from samijaber October 6, 2025 13:10
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2025

🦋 Changeset detected

Latest commit: 46f284c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@builder.io/sdk-angular Patch

Not sure what this means? Click here to learn what changesets are.

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

@yash-builder yash-builder self-assigned this Oct 6, 2025
@yash-builder yash-builder requested a review from a team October 6, 2025 13:10
@nx-cloud
Copy link

nx-cloud bot commented Oct 6, 2025

View your CI Pipeline Execution ↗ for commit 46f284c

Command Status Duration Result
nx test @e2e/angular-19-ssr ✅ Succeeded 5m 21s View ↗
nx test @builder.io/sdks ✅ Succeeded 12s View ↗
nx typecheck @builder.io/sdks ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-24 07:30:20 UTC

@paprikaf paprikaf mentioned this pull request Nov 19, 2025
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.

Could we add some e2e tests for this client-side navigation + repeater issue to make sure we know which SDKs need the fix?

contentId: nextId,
});
}
}, [props.content, props.data, props.locale]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this only needed for angular SDK? If so, lets wrap this new logic in useTarget to make sure it only runs for angular. No need to redundantly update state for other SDKs if they dont need it

Copy link
Contributor

Choose a reason for hiding this comment

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

Added useTarget

@gitguardian
Copy link

gitguardian bot commented Nov 20, 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
22600423 Triggered Generic High Entropy Secret e38b073 packages/sdks/e2e/angular-20-ssr/src/app/catch-all-page/catch-all-page.ts 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.

},
default: () => {},
});
}, [props.content, props.data, props.locale]);
Copy link

Choose a reason for hiding this comment

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

Bug: jsCode not re-executed on content change

When content changes in Angular (detected by ID change), the onUpdate hook updates builderContextSignal.value.content and rootState but doesn't re-execute the new content's jsCode. The jsCode evaluation only happens in onInit (line 180), so when navigating between pages with different content, the new page's jsCode never runs. This causes the new content's state initialization and side effects to be skipped, potentially breaking functionality that depends on jsCode execution.

Fix in Cursor Fix in Web

updateContentAndRootState();
},
default: () => {},
});
Copy link

Choose a reason for hiding this comment

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

Bug: useTarget wrapped in onUpdate not executing

The useTarget call returns a function but never invokes it. The updateContentAndRootState() function will never execute on any target. The return value from useTarget needs to be called to actually execute the Angular-specific logic for resetting builder context when content ID changes.

Fix in Cursor Fix in Web

state.runHttpRequests();
});
}
state.mergeNewContent(props.content);
Copy link

Choose a reason for hiding this comment

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

Bug: Redundant content merge after parent replacement

For Angular, the parent component completely replaces builderContextSignal.value.content when the content ID changes, but the child component unconditionally calls state.mergeNewContent(props.content) on every content update. This creates redundant merging when IDs change and potential race conditions since both components modify the same signal. The child's merge at line 347 should be conditional on the ID not changing, similar to the parent's logic, to avoid conflicts.

Additional Locations (1)

Fix in Cursor Fix in Web

@midhunadarvin
Copy link
Contributor

Could we add some e2e tests for this client-side navigation + repeater issue to make sure we know which SDKs need the fix?

The issue is specific to Angular routerLink. I have recorded a loom here : https://www.loom.com/share/2c4d9541cd2b487e916233337f93e126

Unfortunately, I could not add the e2e test because it depends on httpRequests and when SSR rendered there was no way to mock the http request.

@sanyamkamat sanyamkamat merged commit 5971c7a into BuilderIO:main Nov 24, 2025
92 of 94 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.

4 participants