Преглед на файлове

fix(core): When populating, run search index builder on main process

This prevents issues with sqlite locking tables when running @vendure/create
Michael Bromley преди 6 години
родител
ревизия
6564d3fe8c
променени са 1 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. 7 0
      packages/core/src/plugin/default-search-plugin/default-search-plugin.ts

+ 7 - 0
packages/core/src/plugin/default-search-plugin/default-search-plugin.ts

@@ -1,5 +1,6 @@
 import { Provider } from '@nestjs/common';
 import { Provider } from '@nestjs/common';
 import { SearchReindexResponse } from '@vendure/common/lib/generated-types';
 import { SearchReindexResponse } from '@vendure/common/lib/generated-types';
+import { CREATING_VENDURE_APP } from '@vendure/common/lib/shared-constants';
 import { Type } from '@vendure/common/lib/shared-types';
 import { Type } from '@vendure/common/lib/shared-types';
 import gql from 'graphql-tag';
 import gql from 'graphql-tag';
 
 
@@ -76,6 +77,12 @@ export class DefaultSearchPlugin implements VendurePlugin {
             runInForkedProcess: true,
             runInForkedProcess: true,
         };
         };
         this.options = { ...defaultOptions, ...options };
         this.options = { ...defaultOptions, ...options };
+
+        if (process.env[CREATING_VENDURE_APP]) {
+            // For the "create" step we will not run the indexer in a forked process as this
+            // can cause issues with sqlite locking.
+            this.options.runInForkedProcess = false;
+        }
     }
     }
 
 
     /** @internal */
     /** @internal */