Skip to content

Client throws exception on third disabled third party cookies and Chrome, when running in iFrame #138

@dr-divu

Description

@dr-divu

In Google Chrome, going under Settings > Advanced > Privacy and security > Content Settigns > Block third-party cookies, and enabling the Block third-party cookies option will break the initialize function of the ldclient-js.

Our application is running in an iFrame, hosted on a different domain, so localStorage is considered as a third-party cookie in this scenario.

Wrapping any access to the localStorage object (even checking it's value) in a try catch solves this problem. Currently I have to wrap the whole LaunchDarkly part of the codebase.

Eg.

// throws exception
if (localStorage) localStoorage.getItem('foo)'

// throws exception
localStorage.getItem('foo')

// doesn't throw exception
try {
  localStoorage.getItem('foo)'
} catch (e) {
  // cookies disabled, use default value
}

// throws exception
const client: LDClient = LaunchDarkly.initialize(key, user, options)

// doesn't throw exception

try {
  const client: LDClient = LaunchDarkly.initialize(envApiKey, user, options)
} catch (e) {
  // cookies disabled, use default value
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions