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] Using client.createUserContext leads to setTimeout is not defined error on Akamai EdgeWorker #924

Open
1 task done
dsafonov-grid opened this issue Apr 26, 2024 · 0 comments

Comments

@dsafonov-grid
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

5.3.0

Current Behavior

const optimizelyUserContext = optimizelyClient.createUserContext(userId, udo);

leads to

ReferenceError setTimeout is not defined ReferenceError: setTimeout is not defined%0A at e.onReady (main.js:1:84427)%0A at new e (main.js:1:28336)%0A at e.createUserContext (main.js:1:84961)%0A at main.js:1:93456%0A at Generator.next ()%0A at main.js:1:461%0A at new Promise ()%0A at a (main.js:1:206)%0A at jr (main.js:1:92339)

Expected Behavior

Works same as before

Steps To Reproduce

  1. In Akamai Edge Env
  2. Run your starter kit https://github.com/optimizely/akamai-edgeworker-starter-kit with 5.3.0

SDK Type

Edge/Lite

Node Version

No response

Browsers impacted

No response

Link

No response

Logs

No response

Severity

No response

Workaround/Solution

The cause of this behavior I think is: calling onReady

this.optimizely.onReady().then(({ success }) => {

because stack trace pointed to this
const readyTimeout = setTimeout(onReadyTimeout, timeoutValue);

I can see that you pass shouldIdentifyUser as true to createUserContext all the time.
And another function shouldIdentifyUser as false createInternalUserContext, is private, so for the time being is it ok to use createInternalUserContext and to suppress typescript?

This approach works fine

    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-expect-error
    const optimizelyUserContext = optimizelyClient.createInternalUserContext(userId, udo);

Recent Change

No response

Conflicts

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant