'Shopify Storage Redis Issue with Node React App

I have added session storage in serve.js as follows :-

import SessionHandler from "./SessionHandler";
const sessionStorage = new SessionHandler();

Shopify.Context.initialize({
  API_KEY: process.env.SHOPIFY_API_KEY,
  API_SECRET_KEY: process.env.SHOPIFY_API_SECRET,
  SCOPES: process.env.SCOPES.split(","),
  HOST_NAME: process.env.HOST.replace(/https:\/\//, ""),
  API_VERSION: ApiVersion.October21,
  IS_EMBEDDED_APP: false,
  // This should be replaced with your preferred storage strategy
  //SESSION_STORAGE: new Shopify.Session.MemorySessionStorage(),
  SESSION_STORAGE: new Shopify.Session.CustomSessionStorage(
    sessionStorage.storeCallback,
    sessionStorage.loadCallback,
    sessionStorage.deleteCallback
  ),
});

My router get function is

router.get("(.*)", async (ctx) => {
    const shop = ctx.query.shop;
    let documentQuery = { shop: shop };
    let data = await SessionStorage.findOne(documentQuery);   //this finds the store in the session table
    if (ACTIVE_SHOPIFY_SHOPS[shop] === undefined) {
      if (data == null) {
        ctx.redirect(`/auth?shop=${shop}`);
      } else {
        await handleRequest(ctx);
      }
    } else {
      await handleRequest(ctx);
    }
  });

and than in the SessionHandler file added code as attached in file , but when I run install the app it goes to the storeCallback , loadcallback and deletecallback function multiple times

StoreCallback Function Code

Load and delete callback function code



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source