Semantic-Org/Semantic-UI · warning

Console cannot be restored, most likely it was overwritten o

Error message

Console cannot be restored, most likely it was overwritten outside of module

What it means

This error is logged by Semantic UI's site module when site.console(true) is called to restore the original window.console, but the cached reference (instance.cache.console) is undefined. The module disables console output by replacing window.console with a no-op stub and caches the original; if that cache was never populated (or was cleared), it cannot restore it. The message warns that something outside the module's lifecycle overwrote window.console.

Source

Thrown at src/definitions/globals/site.js:431

  else {
    if(instance !== undefined) {
      module.destroy();
    }
    module.initialize();
  }
  return (returnedValue !== undefined)
    ? returnedValue
    : this
  ;
};

$.site.settings = {

  name        : 'Site',
  namespace   : 'site',

  error : {
    console : 'Console cannot be restored, most likely it was overwritten outside of module',
    method : 'The method you called is not defined.'
  },

  debug       : false,
  verbose     : false,
  performance : true,

  modules: [
    'accordion',
    'api',
    'checkbox',
    'dimmer',
    'dropdown',
    'embed',
    'form',
    'modal',
    'nag',
    'popup',

View on GitHub (pinned to 597843ab84)

Solutions

  1. Ensure site console is disabled ($.site('disable.console')) before attempting to re-enable it; the cache is only populated on disable.
  2. Do not re-initialize the site module ($.site()) after calling destroy(); start fresh on page load.
  3. Remove or defer other scripts that overwrite window.console before site.js loads.
  4. If you never need console suppression, simply avoid calling the console enable/disable API entirely.

Example fix

// before
$.site('enable.console'); // cache is undefined, error logged

// after
$.site('disable.console'); // populates cache
$.site('enable.console');  // now restores correctly
Defensive patterns

Strategy: validation

Validate before calling

// Before calling enable.console, verify the cache exists
if ($.site && typeof $.site === 'function') {
  var instance = $('body').data('module-site');
  if (instance && instance.cache && instance.cache.console) {
    $.site('enable.console');
  } else {
    console.warn('Console cache not available; skip restore.');
  }
}

Type guard

// Check whether the site module's console cache is populated
function canRestoreConsole() {
  var inst = $('body').data('module-site');
  return !!(inst && inst.cache && typeof inst.cache.console === 'object');
}

Prevention

When it happens

Trigger: Calling $.site('enable.console') or $.site('console', true) without a prior disable, or when the module was re-initialized (instance destroyed) after disabling. Also triggered when another library or script has already replaced window.console before site.js cached it, so instance.cache.console stays undefined.

Common situations: Loading order issues where another framework (e.g., a logging shim or testing utility) replaces console before site.js initializes. Calling enable.console after page-level code already wiped or replaced console. Re-initializing the site module on an element after destroy() was called, which clears instance.cache.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/d9157453c8d9e6e9. Report an issue: GitHub.