RocketChat/Rocket.Chat · error · Error

error-running-script

Error message

error-running-script

What it means

An outgoing integration's compiled script threw at runtime while a Trigger method (such as processOutgoingRequest) executed in the sandbox. ScriptEngine logs the real exception under 'Error running Script in Trigger' (with integration name and script) and rethrows this generic error to the caller.

Source

Thrown at apps/meteor/server/lib/integrations/lib/ScriptEngine.ts:367

			});
			return;
		}

		return wrapExceptions(() =>
			this.runScriptMethod({
				integrationId: integration._id,
				script,
				method,
				params,
			}),
		).catch((err: any) => {
			this.logger.error({
				msg: 'Error running Script in Trigger',
				integration: integration.name,
				script: integration.scriptCompiled,
				err,
			});
			throw new Error('error-running-script');
		});
	}

	protected async hasScriptAndMethod(integration: IIntegration, method: keyof IScriptClass): Promise<boolean> {
		const script = await this.getScriptSafely(integration);
		return typeof script?.[method] === 'function';
	}

	protected async getScriptSafely(integration: IIntegration): Promise<Partial<IScriptClass> | undefined> {
		if (this.disabled || integration.scriptEnabled !== true || !integration.scriptCompiled || integration.scriptCompiled.trim() === '') {
			return;
		}

		return wrapExceptions(() => this.getIntegrationScript(integration)).suppress();
	}

	protected abstract isDisabled(): boolean;

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Check server logs for the preceding 'Error running Script in Trigger' entry — it contains the actual error and stack
  2. Fix the script (null-checks, defensive parsing) and re-save the integration so it recompiles
  3. Exercise the script in the integration editor's test/sandbox before re-enabling it
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await triggerHandler.replay(integration, history);
} catch (err) {
  if (err instanceof Error && err.message === 'error-running-script') {
    // script threw at runtime: check server logs for the real stack; fix the script, don't blind-retry
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: An integration with an enabled script whose method throws: TypeError on unexpected payload shapes, missing fields on the request/options data, or calls to undefined helpers during event processing or replay.

Common situations: Remote API response format changed and the script's parsing now fails; script written against a different integration data model; replay of old history whose payload shape differs.

Related errors


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