flarum/framework · info

...args

Error message

...args

What it means

fireDebugWarning is a gate around console.warn: it looks up the 'forums' resource attributes and returns early unless debug is enabled, so warnings only reach the console in debug-mode forums. It is used by deprecation helpers and translations, letting library code emit diagnostics that stay silent for end users.

Solutions

  1. If you're the developer seeing the warning, fix the deprecated usage the message points to.
  2. If warnings must be visible, enable debug mode in the forum admin/settings so attributes.debug is true.
  3. If warnings shouldn't appear, turn debug off — this wrapper intentionally suppresses them.
  4. Ensure the 'forums' resource is present in app.data when bootstrapping custom frontends.
  5. Use fireDebugWarning instead of raw console.warn in extension code to respect debug gating.

Example fix

// before
console.warn('Using legacy API');
// after
import fireDebugWarning from 'flarum/common/helpers/fireDebugWarning';
fireDebugWarning('Using legacy API');
Defensive patterns

Strategy: validation

Validate before calling

const forums = app.data.resources.find((r) => r.type === 'forums');
const debugOn = Boolean(forums?.attributes?.debug);
if (debugOn) {
  fireDebugWarning('my diagnostic message');
}

Type guard

function isDebugMode(app) {
  return Boolean(app?.data?.resources?.find((r) => r.type === 'forums')?.attributes?.debug);
}

Try / catch

if (isDebugMode(app)) {
  try { fireDebugWarning(msg); } catch (e) { /* never let diagnostics break the app */ }
}

Prevention

When it happens

Trigger: Any call to fireDebugWarning(...) (directly or via fireDeprecationWarning, trans, preprocessTranslation, oncreate hooks) when app.data has no 'forums' resource or its attributes.debug is falsy — in which case the warning is silently dropped; otherwise console.warn(...args) fires.

Common situations: Users seeing flarum deprecation/translation warnings in their console after enabling debug mode on production-like data; extension authors confused why their warning doesn't appear because debug is off; missing forums resource in custom bootstraps.

Related errors


AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15). Data as JSON: /api/errors/b46b0a0912d19e5c. Report an issue: GitHub.

Appendix: source

Thrown at framework/core/js/src/common/helpers/fireDebugWarning.ts:17

import app from '../app';

/**
 * Calls `console.warn` with the provided arguments, but only if the forum is in debug mode.
 *
 * This function is intended to provide warnings to extension developers about issues with
 * their extensions that may not be easily noticed when testing, such as accessibility
 * issues.
 *
 * These warnings should be hidden on production forums to ensure webmasters are not
 * inundated with do-gooders telling them they have an issue when it isn't something they
 * can fix.
 */
export default function fireDebugWarning(...args: Parameters<typeof console.warn>): void {
  if (!app.data.resources.find((r) => r.type === 'forums')?.attributes?.debug) return;

  console.warn(...args);
}

/**
 * Fire a Flarum deprecation warning which is shown in the JS console.
 *
 * These warnings are only shown when the forum is in debug mode, and the function exists to
 * reduce bundle size caused by multiple warnings across our JavaScript.
 *
 * @param message The message to display. (Short, but sweet, please!)
 * @param githubId The PR or Issue ID with more info in relation to this change.
 * @param [removedFrom] The version in which this feature will be completely removed. (default: 2.0)
 * @param [repo] The repo which the issue or PR is located in. (default: flarum/core)
 *
 * @see {@link fireDebugWarning}
 */
export function fireDeprecationWarning(message: string, githubId: string, removedFrom: string = '2.0', repo: string = 'flarum/core'): void {
  // GitHub auto-redirects between `/pull` and `/issues` for us, so using `/pull` saves 2 bytes!
  fireDebugWarning(`[Flarum ${removedFrom} Deprecation] ${message}\n\nSee: https://github.com/${repo}/pull/${githubId}`);

View on GitHub (pinned to 4b939f6853)