Skip to content

[nextjs][pages] Soft-fail scClient requests when browser context ID is missing - #644

Merged
art-alexeyenko merged 4 commits into
devfrom
bug/jss-10377-styles-and-client
Oct 6, 2026
Merged

art-alexeyenko merged 4 commits into
devfrom
bug/jss-10377-styles-and-client

Conversation

@art-alexeyenko

@art-alexeyenko art-alexeyenko commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Description / Motivation

Pages router apps can fail a render when a client context ID is missing. This can mainly be observed in rendering SitecoreStyles component in CSDK Layout, that calls scClient.getHeadLinks(). It can also occur when scClient.getPage and other methods are called in shared server/browser context.
The current implementation of SitecoreClient + GraphQL client is tacitly accepting a situation when context ID is absent during initialization in browser context, despite the browser scClient instance being not useful. This leads to issues and exceptions arising later.
The proposed fix is adding a couple of guards to soft-land a contextId-less scClient:

  • No-op fallback GraphQL client to be called in browser when context ID is not set (with extra logging). This communicates the state of scClient correctly without waiting for an error to occur.
  • A validation flag to be set when both server and client context ID are missing - to be used in getHeadLinks and handles their absence correctly.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@changeset-bot

changeset-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c59f354

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

This PR includes changesets to release 1 package
Name Type
@sitecore-content-sdk/content 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

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 69.05 KB 69.05 KB ✅ 0.00 KB 97.44% 97.44% 0.00%
angular 438.39 KB 438.39 KB ✅ 0.00 KB 94.22% 94.22% 0.00%
cli 84.63 KB 84.63 KB ✅ 0.00 KB 77.84% 77.84% 0.00%
content 524.22 KB 525.88 KB 🔺 +1.66 KB 93.18% 93.10% -0.08%
core 139.38 KB 139.38 KB ✅ 0.00 KB 91.80% 91.80% 0.00%
create-content-sdk-app 551.33 KB 551.33 KB ✅ 0.00 KB 96.47% 96.47% 0.00%
events 72.33 KB 72.33 KB ✅ 0.00 KB 97.97% 97.97% 0.00%
nextjs 585.07 KB 585.07 KB ✅ 0.00 KB 91.79% 91.79% 0.00%
personalize 64.01 KB 64.01 KB ✅ 0.00 KB 99.74% 99.74% 0.00%
react 254.44 KB 254.44 KB ✅ 0.00 KB 93.83% 93.83% 0.00%
search 16.69 KB 16.69 KB ✅ 0.00 KB 98.89% 98.89% 0.00%
Total — — 🔺 +1.66 KB — — —

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me 👍
Please, see a couple of comments below

Comment thread packages/content/src/client/sitecore-client.ts
Comment thread .changeset/jss-10377-scClient-fallback.md Outdated
Comment thread packages/content/src/client/utils.ts
Comment thread packages/content/src/client/utils.ts Outdated
@art-alexeyenko
art-alexeyenko merged commit 5184ea7 into dev Oct 6, 2026
5 checks passed
@art-alexeyenko
art-alexeyenko deleted the bug/jss-10377-styles-and-client branch October 6, 2026 18:05
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.

2 participants