RocketChat/Rocket.Chat · error · Error

The current import operation can not receive new data.

Error message

The current import operation can not receive new data.

What it means

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.

Source

Thrown at apps/meteor/server/services/import/service.ts:104

		}

		const state = this.getStateOfOperation(operation);

		return {
			state,
			operation,
		};
	}

	private assertsValidStateForNewData(operation: IImport | undefined): asserts operation is IImport {
		if (!operation?.valid) {
			throw new Error('Import operation not initialized.');
		}
		const state = this.getStateOfOperation(operation);
		switch (state) {
			case 'loading':
			case 'importing':
				throw new Error('The current import operation can not receive new data.');
			case 'done':
			case 'error':
			case 'canceled':
				throw new Error('The current import operation is already finished.');
		}
	}

	public async addUsers(users: Omit<IImportUser, '_id' | 'services' | 'customFields'>[]): Promise<void> {
		if (!users.length) {
			return;
		}

		const operation = await Imports.findLastImport();

		this.assertsValidStateForNewData(operation);

		const defaultRoles = getNewUserRoles();
		const userRoles = new Set<string>(defaultRoles);

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Wait until the operation leaves 'loading'/'importing' (e.g. reaches 'importer_user_selection') before adding more data
  2. Serialize the import pipeline so only one phase runs at a time
  3. Batch all records into the loading phase before calling run()
Defensive patterns

Strategy: validation

Validate before calling

const op = await Imports.findLastImport();
if (['loading', 'importing'].includes(op?.status ?? '')) {
  throw new Error('import is busy; queue the batch until it accepts data');
}
await service.addUsers(users);

Type guard

function importAcceptsData(op: IImport | undefined): boolean {
  return Boolean(op?.valid) && !['loading', 'importing', 'done', 'error', 'canceled'].includes(op.status);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/793529426f22fcaf. Report an issue: GitHub.