octobercms/october · error · Error

Snackbar options.timeout must be a number

Error message

Snackbar options.timeout must be a number

What it means

Generic type guard inside the Snackbar's validateOptions helper: it fires whenever the snackbar() method is called with an options object whose timeout property is set but is not a number (e.g. a string like '2000'). The developer must pass timeout as a numeric millisecond value.

Solutions

  1. Pass timeout as a number, e.g. {timeout: 5000}, not a string like '5000'
  2. Parse/convert user-supplied durations to numbers before invoking the snackbar
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at modules/backend/assets/js/october/october.snackbar.js:38 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/1210cff485bba3ae. Report an issue: GitHub.

Appendix: source

Thrown at modules/backend/assets/js/october/october.snackbar.js:38

        function validateOptions(options) {
            if (options === undefined) {
                return;
            }

            if (typeof options !== 'object') {
                throw new Error('Snackbar options must be an object');
            }

            if (options.replace !== undefined) {
                if (typeof options.replace !== 'number') {
                    throw new Error('Snackbar options.replace must be a number');
                }
            }

            if (options.timeout !== undefined) {
                if (typeof options.timeout !== 'number') {
                    throw new Error('Snackbar options.timeout must be a number');
                }

                if (options.timeout < 2000) {
                    throw new Error('Snackbar options.timeout cannot be lower than 2000');
                }

                if (options.timeout > 8000) {
                    throw new Error('Snackbar options.timeout cannot be higher than 8000');
                }
            }

            if (options.action !== undefined) {
                if (typeof options.action !== 'object') {
                    throw new Error('Snackbar options.action must be an object');
                }

                if (typeof options.action.label !== 'string') {
                    throw new Error('Snackbar options.action.label must be a string');

View on GitHub (pinned to b608633a7e)