diff --git a/packages/core/src/plugin/default-search-plugin/indexer/index-builder.ts b/packages/core/src/plugin/default-search-plugin/indexer/index-builder.ts index 06cf30cf20..a62f3467f7 100644 --- a/packages/core/src/plugin/default-search-plugin/indexer/index-builder.ts +++ b/packages/core/src/plugin/default-search-plugin/indexer/index-builder.ts @@ -94,7 +94,7 @@ export class IndexBuilder { private async connect(dbConnectionOptions: ConnectionOptions): Promise { const {coreEntitiesMap} = await import('../../../entity/entities'); const coreEntities = Object.values(coreEntitiesMap) as Array>; - this.connection = await createConnection({...dbConnectionOptions, entities: [SearchIndexItem, ...coreEntities]}); + this.connection = await createConnection({...dbConnectionOptions, entities: [SearchIndexItem, ...coreEntities], name: 'index-builder' }); this.indexQueryBuilder = getSearchIndexQueryBuilder(this.connection); return new ConnectedMessage(this.connection.isConnected); } diff --git a/packages/core/src/plugin/default-search-plugin/indexer/search-index.service.ts b/packages/core/src/plugin/default-search-plugin/indexer/search-index.service.ts index 8d80a25984..f79c18ee0b 100644 --- a/packages/core/src/plugin/default-search-plugin/indexer/search-index.service.ts +++ b/packages/core/src/plugin/default-search-plugin/indexer/search-index.service.ts @@ -34,6 +34,9 @@ import { SaveVariantsMessage, VariantsSavedMessage, } from './ipc'; +// This import is needed to ensure that the worker script gets compiled +// and emitted during build. +import './search-index-worker'; export type IncomingMessage = ConnectedMessage | ReturnRawBatchMessage | VariantsSavedMessage | CompletedMessage; const loggerCtx = 'DefaultSearchPlugin'; @@ -58,7 +61,7 @@ export class SearchIndexService { * Creates the search index worker process and has it connect to the database. */ async connect() { - if (this.options.runInForkedProcess) { + if (this.options.runInForkedProcess && this.configService.dbConnectionOptions.type !== 'sqljs') { try { const workerProcess = this.getChildProcess(path.join(__dirname, 'search-index-worker.ts')); Logger.verbose(`IndexBuilder running as forked process`, loggerCtx); @@ -122,6 +125,7 @@ export class SearchIndexService { const variants = await this.getBatch(this.workerProcess, i); const hydratedVariants = this.hydrateVariants(ctx, variants); + Logger.verbose(`variants count: ${variants.length}`); ipcChannel.send(new SaveVariantsMessage({ variants: hydratedVariants, @@ -275,7 +279,7 @@ export class SearchIndexService { private establishConnection(child: ChildProcess): Promise { const connectionOptions = pick(this.configService.dbConnectionOptions as any, - ['type', 'name', 'database', 'host', 'port', 'username', 'password']); + ['type', 'name', 'database', 'host', 'port', 'username', 'password', 'location', 'autoSave']); return new Promise(resolve => { const ipcChannel = new IpcChannel(child); ipcChannel.subscribe(MessageType.CONNECTED, message => {