{"record":{"id":"793529426f22fcaf","repo":"RocketChat/Rocket.Chat","slug":"the-current-import-operation-can-not-receive-new-d","errorCode":null,"errorMessage":"The current import operation can not receive new data.","messagePattern":"The current import operation can not receive new data\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/import/service.ts","lineNumber":104,"sourceCode":"\t\t}\n\n\t\tconst state = this.getStateOfOperation(operation);\n\n\t\treturn {\n\t\t\tstate,\n\t\t\toperation,\n\t\t};\n\t}\n\n\tprivate assertsValidStateForNewData(operation: IImport | undefined): asserts operation is IImport {\n\t\tif (!operation?.valid) {\n\t\t\tthrow new Error('Import operation not initialized.');\n\t\t}\n\t\tconst state = this.getStateOfOperation(operation);\n\t\tswitch (state) {\n\t\t\tcase 'loading':\n\t\t\tcase 'importing':\n\t\t\t\tthrow new Error('The current import operation can not receive new data.');\n\t\t\tcase 'done':\n\t\t\tcase 'error':\n\t\t\tcase 'canceled':\n\t\t\t\tthrow new Error('The current import operation is already finished.');\n\t\t}\n\t}\n\n\tpublic async addUsers(users: Omit<IImportUser, '_id' | 'services' | 'customFields'>[]): Promise<void> {\n\t\tif (!users.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst operation = await Imports.findLastImport();\n\n\t\tthis.assertsValidStateForNewData(operation);\n\n\t\tconst defaultRoles = getNewUserRoles();\n\t\tconst userRoles = new Set<string>(defaultRoles);","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/services/import/service.ts#L86-L122","documentation":"Thrown by assertsValidStateForNewData when the last valid import operation is in state 'loading' or 'importing'. While an import is actively loading data or executing, the operation cannot accept new records, so any add* call in that window throws this Error.","triggerScenarios":"Calling addUsers/addChannels/addMessages while the same operation is already loading (two workers feeding one import); uploading new files after the run started; polling loops that retry the upload while the first attempt is mid-load.","commonSituations":"Parallel import workers without coordination; UIs that let users drop more files while the progress spinner is still in the loading phase; retry logic that re-sends batches after run() began.","solutions":["Wait until the operation leaves 'loading'/'importing' (e.g. reaches 'importer_user_selection') before adding more data","Serialize the import pipeline so only one phase runs at a time","Batch all records into the loading phase before calling run()"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const op = await Imports.findLastImport();\nif (['loading', 'importing'].includes(op?.status ?? '')) {\n  throw new Error('import is busy; queue the batch until it accepts data');\n}\nawait service.addUsers(users);","typeGuard":"function importAcceptsData(op: IImport | undefined): boolean {\n  return Boolean(op?.valid) && !['loading', 'importing', 'done', 'error', 'canceled'].includes(op.status);\n}","tryCatchPattern":null,"preventionTips":["Serialize import workers so only one phase touches the operation","Finish loading all records before calling run()"],"tags":["import","state-machine","concurrency","rocket-chat"],"backgroundTag":"invalid-operation-state","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}