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

Cache Policy Errors at runtime #57

Open
ADNolan opened this issue Oct 8, 2024 · 1 comment
Open

Cache Policy Errors at runtime #57

ADNolan opened this issue Oct 8, 2024 · 1 comment

Comments

@ADNolan
Copy link

ADNolan commented Oct 8, 2024

I am attempting to use the SDK cache feature and running into an error with the following configuration. current package version is
@contentstack/delivery-sdk": "4.3.0

{
    policy: 'NETWORK_ELSE_CACHE',
    storeType: 'memoryStorage',
    maxAge: 600000
  }
TypeError [Error]: defaultAdapter is not a function
        at <anonymous> (node_modules/@contentstack/delivery-sdk/src/lib/cache.ts:17:33)
        at Generator.next (<anonymous>)
        at node_modules/tslib/tslib.js:169:75
        at new Promise (<anonymous>)
        at Object.__awaiter (node_modules/tslib/tslib.js:165:16)
        at handleRequest (node_modules/@contentstack/delivery-sdk/src/lib/cache.ts:12:14)
        at Object.<anonymous> (node_modules/@contentstack/delivery-sdk/src/lib/contentstack.ts:97:30)
        at Generator.next (<anonymous>)
        at node_modules/tslib/tslib.js:169:75
        at new Promise (<anonymous>)

When setting to use a different policy, another error arises.

{
    policy: 'CACHE_ELSE_NETWORK',
    storeType: 'memoryStorage',
    maxAge: 600000
  }
 TypeError [Error]: Cannot read properties of undefined (reading 'getItem')
      at Object.getItem (node_modules/@contentstack/delivery-sdk/src/persistance/storages/local-storage.ts:36:25)
      at PersistanceStore.getItem (node_modules/@contentstack/delivery-sdk/src/persistance/persistance-store.ts:64:32)
      at <anonymous> (node_modules/@contentstack/delivery-sdk/src/lib/cache.ts:59:40)
      at Generator.next (<anonymous>)
      at node_modules/tslib/tslib.js:169:75
      at new Promise (<anonymous>)
      at Object.__awaiter (node_modules/tslib/tslib.js:165:16)
      at handleRequest (node_modules/@contentstack/delivery-sdk/src/lib/cache.ts:12:14)
      at Object.<anonymous> (node_modules/@contentstack/delivery-sdk/src/lib/contentstack.ts:97:30)
      at Generator.next (<anonymous>)

The errors occur regardless of the storeType that is configured for the cache options. A sample of the stack config is

{
  host: 'cdn.**-contentstack.com',
  apiKey: '***',
  deliveryToken: '***',
  environment: 'qa',
  cacheOptions: { policy: 'CACHE_ELSE_NETWORK', storeType: 'localStorage' },
  timeout: 5000,
  retryLimit: 3,
  retryDelay: 500
}
@cs-raj
Copy link
Contributor

cs-raj commented Nov 7, 2024

Hi @ADNolan we have taken this issue and we will update once we verify and resolve from our end

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

No branches or pull requests

2 participants