Skip to content
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

fix: use resolved server data in non-streaming mode #1006

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import React, { Suspense, use, useEffect, useRef } from 'react'

Check warning on line 2 in sdk/nextjs/src/client/internal/InternalDevCycleClientsideProvider.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

'useEffect' is defined but never used
import { DevCycleClient, initializeDevCycle } from '@devcycle/js-client-sdk'
import { invalidateConfig } from '../../common/invalidateConfig'
import { DevCycleNextOptions, DevCycleServerData } from '../../common/types'
Expand Down Expand Up @@ -112,18 +112,17 @@
})

if (!enableStreaming) {
const resolvedServerData = use(serverDataPromise)
// we expect that either the promise has resolved and we got the server data that way, or we weren't in
// streaming mode and so the promise was awaited at a higher level and passed in here as serverData
if (!resolvedServerData) {
// we expect that in non-streaming mode, the serverside portion of this provider should have awaited
// the serverDataPromise and passed in the result here
if (!serverData) {
throw new Error(
'Server data should be available. Please contact DevCycle support.',
)
}
clientRef.current.synchronizeBootstrapData(
resolvedServerData.config,
resolvedServerData.user,
resolvedServerData.userAgent,
serverData.config,
serverData.user,
serverData.userAgent,
)
}
}
Expand Down
Loading