Hi Descope team :wave: I’m facing an issue with ex...
# ask-a-descoper
a
Hi Descope team 👋 I’m facing an issue with excessive loading time during Descope initialization in a React (Vite) app. Setup:
@descope/react-sdk
Issue: The initial load takes noticeably long , even when the user is already logged out. This causes a visible delay before routing or rendering the login screen. Questions: • Is this expected behavior during Descope SDK initialization? • Are there recommended optimizations (lazy loading, preloading, config flags, etc.)? • Any best practices to reduce initial auth loading time in SPAs?
p
@Atharva Joshi
a
@Aryan Bhandari could you specify the version of the react sdk your using? And a screenshot of the network tab during initial auth would be helpful as well
a
V 2..25.0 i am using console error Setting refresh timer for 150152. (579011ms) Profile.tsx:84 Logging out... index.esm.js:1 Clearing all timers loggerMixin.js:27 Successfully fetched URL https://static.descope.com/pages/P34BHLas1imEyKtqssBSuha6Hbxu/v2-beta/theme.json loggerMixin.js:27 Fetched theme Object loggerMixin.js:27 Successfully fetched URL https://static.descope.com/pages/P34BHLas1imEyKtqssBSuha6Hbxu/v2-beta/config.json loggerMixin.js:27 Got component version "2.2.9" loggerMixin.js:27 Injecting npm lib: "@descope/web-components-ui" with version: "2.2.9" loggerMixin.js:27 DescopeUI was loaded loggerMixin.js:27 Before popup postmessage send {"isPopup":false,"isCodeChanged":false,"isExchangeErrorChanged":false} loggerMixin.js:27 Got a screen with id sign-up-or-in/SC2fmFlEcLGc1e8RDBhxdmQhIYzi6 loggerMixin.js:27 Enable key press handler loggerMixin.js:27 Rendering a flow screen loggerMixin.js:27 Successfully fetched URL https://static.descope.com/pages/P34BHLas1imEyKtqssBSuha6Hbxu/v2-beta/sign-up-or-in/SC2fmFlEcLGc1e8RDBhxdmQhIYzi6.html descopeUiMixin.js:54 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'descope-container') at Ti.o (descopeUiMixin.js5418) at async Promise.all (:3131/index 0)
import { Descope } from '@descope/react-sdk'; import { Box } from '@mui/material'; import { useLocation, useNavigate } from 'react-router-dom'; import LoginSkeleton from '../sections/skeleton/login/LoginSkeleton'; import { useState } from 'react'; export default function Login() { const navigate = useNavigate(); const location = useLocation(); const [isLoading, setIsLoading] = useState(true); const handleSuccess = () => { const params = new URLSearchParams(location.search); const redirectTo = params.get('redirect') ?? '/marketplace'; void navigate(redirectTo, { replace: true }); }; return ( <> {isLoading && ( <Box sx={{ position: 'absolute', inset: 0, zIndex: 10, }} > <LoginSkeleton /> </Box> )} <Box sx={{ minWidth: 500, visibility: !isLoading ? 'visible' : 'hidden', boxShadow: '0 4px 8px rgba(0,0,0,0.2)', border: '1px solid #ddd', padding: '16px 16px 36px', backgroundColor: '#fff', borderRadius: '8px', }} > <Descope flowId="sign-up-or-in" restartOnError onSuccess={handleSuccess} onReady={() => setIsLoading(false)} onError={(e) => { console.error('DESCOPE ERROR:', e); setIsLoading(false); }} /> </Box> </> ); }
a
let me check this
@Aryan Bhandari I tested your setup and looks like the latency is under 200ms Is it possible you have some additional network settings at your end that might increase latency?
a
The error is coming when i am logging in to my website, spending some time scrolling though the site after loggin out , my login page is showing skeleton for a long time very very long time
image.png
image.png
a
can you turn on the Fetch/XHR option so i can check the component call that renders your component?
a
image.png
this is taking some 10-12 seconds some req are in pending state
a
even though the log shows 327ms for the component call? this might be something in your setup like an API call that is delaying the rendering ?
a
Sir , can we somehow connect on meet ?
a
sure does 5:30 PM sound good?
a
yess sir
should i paste link in this chat only
a
Ill DM you a link shortly
a
okay sir
Copy code
uccessfully fetched URL <https://static.descope.com/pages/P34ixVh0LRlEd09OkvD4EPsV8Aj4/v2-beta/config.json> loggerMixin.js:27:81
Got component version "2.1.17" loggerMixin.js:27:81
Injecting npm lib: "@descope/web-components-ui" with version: "2.1.17" loggerMixin.js:27:81
DescopeUI was loaded loggerMixin.js:27:81
Successfully fetched URL <https://static.descope.com/pages/P34ixVh0LRlEd09OkvD4EPsV8Aj4/v2-beta/theme.json> loggerMixin.js:27:81
Fetched theme 
Object { dark: {…}, light: {…} }
 loggerMixin.js:27:81
Before popup postmessage send {"isPopup":false,"isCodeChanged":false,"isExchangeErrorChanged":false} loggerMixin.js:27:81
Got a screen with id sign-up-or-in/SC2fmFlEcLGc1e8RDBhxdmQhIYzi6 loggerMixin.js:27:81
Rendering a flow screen <empty string> loggerMixin.js:27:81
Successfully fetched URL <https://static.descope.com/pages/P34ixVh0LRlEd09OkvD4EPsV8Aj4/v2-beta/sign-up-or-in/SC2fmFlEcLGc1e8RDBhxdmQhIYzi6.html> loggerMixin.js:27:81
Uncaught (in promise) TypeError: can't access property "descope-container", h is undefined
    n descopeUiMixin.js:54
    loadDescopeUiComponents descopeUiMixin.js:28
    loadDescopeUiComponents descopeUiMixin.js:28
    onStepChange DescopeWc.js:1
    b tslib.es6.mjs:118
    promise callback*T tslib.es6.mjs:120
    uy tslib.es6.mjs:121
    uy tslib.es6.mjs:117
    onStepChange DescopeWc.js:1
    update state.js:1
    update state.js:1
    setTimeout handler*fe/this.update state.js:1
    onFlowChange DescopeWc.js:1
    b tslib.es6.mjs:118
    promise callback*T tslib.es6.mjs:120
    b tslib.es6.mjs:118
    promise callback*T tslib.es6.mjs:120
    b tslib.es6.mjs:118
    promise callback*T tslib.es6.mjs:120
    b tslib.es6.mjs:118
    promise callback*T tslib.es6.mjs:120
    uy tslib.es6.mjs:121
    uy tslib.es6.mjs:117
    onFlowChange DescopeWc.js:1
    update state.js:1
    update state.js:1
    setTimeout handler*fe/this.update state.js:1
    pi BaseDescopeWc.js:1
    uy tslib.es6.mjs:121
    uy tslib.es6.mjs:117
    pi BaseDescopeWc.js:1
    update state.js:1
    update state.js:1
    setTimeout handler*fe/this.update state.js:1
    init BaseDescopeWc.js:1
    b tslib.es6.mjs:118
    promise callback*T tslib.es6.mjs:120
    b tslib.es6.mjs:118
a
Thankyou for sharing this @Aryan Bhandari Let me pass this on internally We'll review and update here ASAP
a
Thankyou so much
🙌 1
a
Hey @Aryan Bhandari the team requested a HAR file for this incident This will help us better understand why this error is occuring
a
localhost.har
a
Hey aryan Thanks for sharing this I'll pass this on internally and get back to you with an update
a
Okay sir
tried next js as welll
still coming
a
After reviewing the HAR file the slowest descope network call is ~1s not 35s as we saw on call that day i think there might be other calls that might be slowing down your rendering