travis-r6s/gridsome-plugin-flexsearch

Getting error RangeError: Maximum call stack size exceeded after upgrading to Gridsome 0.7.17

jxlstudio opened this issue · 6 comments

Error happens when running Develop mode.

RangeError: Maximum call stack size exceeded
    at Object.entries.reduce (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:42)
    at Array.reduce (<anonymous>)
    at parseObject (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:35)
    at Object.entries.reduce (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:85)
    at Array.reduce (<anonymous>)
    at parseObject (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:35)
    at Object.entries.reduce (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:85)
    at Array.reduce (<anonymous>)
    at parseObject (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:35)
    at Object.entries.reduce (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:85)
    at Array.reduce (<anonymous>)
    at parseObject (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:35)
    at Object.entries.reduce (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:85)
    at Array.reduce (<anonymous>)
    at parseObject (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:35)
    at Object.entries.reduce (/REPONAME/node_modules/gridsome-plugin-flexsearch/gridsome.server.js:42:85)
Environment: 
  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  Binaries:
    Node: 10.16.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 83.0.4103.97
    Firefox: 77.0.1
    Safari: 13.1.1
  npmPackages:
    @gridsome/plugin-sitemap: ^0.2.3 => 0.2.3 
    @gridsome/source-airtable: ^0.1.4 => 0.1.4 
    @gridsome/source-contentful: ^0.5.2 => 0.5.2 
    @gridsome/transformer-remark: ^0.4.0 => 0.4.0 
    gridsome: ^0.7.13 => 0.7.17 
    gridsome-plugin-algolia: ^2.1.3 => 2.1.3 
    gridsome-plugin-flexsearch: ^0.1.15 => 0.1.20 
    gridsome-plugin-gtm: ^0.1.1 => 0.1.1 
    gridsome-plugin-modal: ^0.1.1 => 0.1.1 
    gridsome-plugin-tailwindcss: ^2.2.32 => 2.2.48 
    gridsome-source-shopify: ^0.1.9 => 0.1.13 
  npmGlobalPackages:
    @gridsome/cli: 0.2.1

Also, I'm not using Algolia, it is not included in my config file.

So I tried commenting out certain types of entries to see what works and what doesn't, and have it boiled down to only 3 entry types, still can't figure out why these types are triggering the error.

@jxlstudio That's strange, but thanks for reporting - would you be able to paste your gridsome config please?

@jxlstudio Do you still have this issue? I haven't seen this issue at all on any other sites.

@jxlstudio Did you see the above comments?

I never really fixed this, I just didn't index the problem collection.

I just upgraded this flexsearch plugin, and am now having the issue with a different collection.

It seems that when a field has multiple nested values in its array, it gives me the "RangeError: Maximum call stack size exceeded" error.

The config is below, I have inserted a comment where the problem is with additional notes. The collection is pulled from Contentful, so the Asset's file field schema file follows as such.

{
      use: 'gridsome-plugin-flexsearch',
      options: {
        chunk: true,
        // compress: true,
        autoFetch: '/search-results',
        collections: [
          {
            typeName: 'Product',
            indexName: 'Product',
            fields: ['title', 'slug', 'pageSummary', 'seoTitle']
          },
          {
            typeName: 'ParentSolution',
            indexName: 'ParentSolution',
            fields: ['title', 'slug', 'pageSummary', 'seoTitle']
          },
          {
            typeName: 'ChildSolution',
            indexName: 'ChildSolution',
            fields: ['title', 'slug', 'pageSummary', 'seoTitle']
          },
          {
            typeName: 'ProHubPage',
            indexName: 'ProHubPage',
            fields: ['title', 'slug', 'description', 'seoTitle']
          },
/// the Asset collection is the problem, when I remove the 'file' field, it doesn't give the error.
          {
            typeName: 'Asset',
            indexName: 'Asset',
            fields: ['title', 'file']
          },
          {
            typeName: 'CaseStudy',
            indexName: 'CaseStudy',
            fields: ['title', 'originalPostLink', 'featImg']
          },
          {
            typeName: 'Video',
            indexName: 'Video',
            fields: ['title', 'caption', 'link']
          },
          {
            typeName: 'BlogPost',
            indexName: 'BlogPost',
            fields: ['title', 'originalPostLink', 'featImg']
          },
          {
            typeName: 'BasicPage',
            indexName: 'BasicPage',
            fields: ['title', 'seoTitle', 'pageSummary']
          }
        ],
        searchFields: {
          title: {
            encode: "extra",
            tokenize: "full"
          },
          seoTitle: {
            encode: "extra",
            tokenize: "full"
          },
          pageSummary: {
            encode: "icase",
            tokenize: "forward"
          },
          summary: {
            encode: "icase",
            tokenize: "forward"
          },
          caption: {
            encode: "icase",
            tokenize: "forward"
          },
        }
      }
    }