Immutable solution version
`initializeDevCycle.onClientInitialized()` does not throw error when connection to DVC APIs fail
Complete solution
Shows how to fix `initializeDevCycle.onClientInitialized()` does not throw error when connection to DVC APIs fail. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Fixed in @devcycle/js-client-sdk v1.28.7. If you hit init problems on the DevCycle JS SDK, upgrade to 1.28.7 or later and keep a try/catch around onClientInitialized so defaults are used when init fails.
Steps
- Fixed in @devcycle/js-client-sdk v1.28.7. Before that, an invalid SDK key or an unreachable DevCycle server meant onClientInitialized never threw and identifyUser could hang, blocking app load. After the fix, an invalid key falls back to your default flag values as intended, and the hanging behavior when the server can't be reached is fixed too. If you hit init problems on the DevCycle JS SDK, upgrade to 1.28.7 or later and keep a try/catch around onClientInitialized so defaults are used when init fails.
When to use
You are seeing this: Issue DevCycleHQ/js-sdks#913 (closed, 9 comments): I have recently included DevCycle in my application and experienced unexpected behavior. Use this skill when you run into "initializeDevCycle.onClientInitialized() does not throw error when connection to DVC APIs fail".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: devcyclejs-client-sdk v1.28.7, 1.28.7. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
In gh:DevCycleHQ/js-sdks#913 (DevCycle), the issue reported was: Issue DevCycleHQ/js-sdks#913 (closed, 9 comments): I have recently included DevCycle in my application and experienced unexpected behavior. My expectation is that the client should not initialize if DVC cannot be reached or an invalid client SDK key is provided. ### Reproduce steps #### Scenario 1 An invalid SDK key is provided to the client. #### Scenario 2 The DVC server cannot be reached. I was able to reproduce this by blocking network requests to DVC servers in Chrome devtools. The verified resolution from the thread: Fixed in @devcycle/js-client-sdk v1.28.7. Before that, an invalid SDK key or an unreachable DevCycle server meant onClientInitialized never threw and identifyUser could hang, blocking app load. After the fix, an invalid key falls back to your default flag values as intended, and the hanging behavior when the server can't be reached is fixed too. If you hit init problems on the DevCycle JS SDK, upgrade to 1.28.7 or later and keep a try/catch around onClientInitialized so defaults are used when init fails. Source: mount the host path https at container path //github.com/DevCycleHQ/js-sdks/issues/913
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Rw-5Sro9dvHExura0iWUYg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">`initializeDevCycle.onClientInitialized()` does not throw error when connection to DVC APIs fail <span>— Vectle</span></a>