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

[BUG] useDecision with autoUpdate:false runs into error "Unable to evaluate feature "..." because User ID is not set." #234

Closed
1 task done
fabb opened this issue Jan 26, 2024 · 8 comments
Labels
acknowledged bug Something isn't working

Comments

@fabb
Copy link

fabb commented Jan 26, 2024

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

3.0.0

Current Behavior

I have an OptimizelyProvider in a 'use client' component that is SSRed. It receives the user directly on the initial render.

In another 'use client' component that is SSRed, I use useDecision with autoUpdate:false.

The output of useDecision is an error: "Unable to evaluate feature "..." because User ID is not set."

Expected Behavior

Since the OptimizelyProvider receives the user directly during SSR, I would expect that useDecision already contains the correct decision for that user, and the according variant can be server rendered.

Steps To Reproduce

export const CustomOptimizelyProvider = (props) => {
    const [optimizely] = useState(() =>
        createInstance({
            datafile: props.optimizelyDatafile, // this is fetched synchronously in a server component, so we already have it
        }),
    )

    return <OptimizelyProvider optimizely={optimizely} isServerSide={true} user={props.optimizelyUser} children={props.children} />
}
const Page = () => {
    const [decision] = useDecision('beast-test')
    return <div>decision: {decision}<div>
}

Might be related to #185

React Framework

next.js 14.0.4

Browsers impacted

all

Link

No response

Logs

No response

Severity

Blocking development

Workaround/Solution

none found yet except for autoUpdate:true which I want to avoid since the SSR result should already be the correct variant.

Recent Change

I think it was not an issue in the previous major version, but I only tried it in another project, because the current project is new.

Conflicts

No response

@mikechu-optimizely
Copy link
Contributor

mikechu-optimizely commented Jan 26, 2024

@fabb , Thanks for the early report. I need to add e2e SSR test. Grrrr. That's on me.

I created a work ticket (FSSDK-9975) for a short turnaround.

@alexparish
Copy link

@mikechu-optimizely Sorry to nudge, but I don't suppose you have an ETA on this fix? It's a blocker to upgrading to v3, which itself seems to be required for the library to work with the Next.js App Router.

@mikechu-optimizely
Copy link
Contributor

Hey. Thanks for the nudge.

This ticket got bumped for a severity 1 to keep the sprint points level, but grrr it got put into Planning instead of just bumped forward a sprint.

I've pulled it into next week's sprint start.

@fabb
Copy link
Author

fabb commented Apr 5, 2024

@mikechu-optimizely how is progress going?

@mikechu-optimizely
Copy link
Contributor

Hi @fabb. I'm working to get #255 approved.

@mikechu-optimizely
Copy link
Contributor

Hi again @fabb Can you review v3.1.0 in your implementation?

@fabb
Copy link
Author

fabb commented Apr 12, 2024

@mikechu-optimizely thank you, it works now correctly!

@fabb fabb closed this as completed Apr 12, 2024
@mikechu-optimizely
Copy link
Contributor

Woot w00t. 🎉 Thanks for the collab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants