sveltejs/kit · warning

${route_id}: Calling `depends('${dep}')` will throw an error

Error message

${route_id}: Calling `depends('${dep}')` will throw an error in Firefox because `${match[1]}` is a special URI scheme

What it means

`depends()` URLs must be ordinary fetchable URLs because SvelteKit uses them for invalidation tracking. Firefox throws for special URI schemes, so SvelteKit warns at dev time when `moz-icon:`, `view-source:`, or `jar:` schemes are used.

Source

Thrown at packages/kit/src/runtime/shared.js:12

import * as devalue from 'devalue';
import { base64_decode, base64_encode, text_decoder, text_encoder } from './utils.js';
import { decoders, encoders } from '#app/internal/transport';

/**
 * @param {string} route_id
 * @param {string} dep
 */
export function validate_depends(route_id, dep) {
	const match = /^(moz-icon|view-source|jar):/.exec(dep);
	if (match) {
		console.warn(
			`${route_id}: Calling \`depends('${dep}')\` will throw an error in Firefox because \`${match[1]}\` is a special URI scheme`
		);
	}
}

export const INVALIDATED_PARAM = 'x-sveltekit-invalidated';

export const TRAILING_SLASH_PARAM = 'x-sveltekit-trailing-slash';

/**
 * @param {any} data
 * @param {string} [location_description]
 */
export function validate_load_response(data, location_description) {
	if (data != null && Object.getPrototypeOf(data) !== Object.prototype) {
		throw new Error(
			`a load function ${location_description} returned ${
				typeof data !== 'object'

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Use a custom namespaced key like `depends('app:asset:' + id)` instead of a special scheme
  2. Sanitize/reject deps matching /^(moz-icon|view-source|jar):/ before calling depends
  3. Strip the scheme or re-encode the resource reference as a normal path

Example fix

// before
depends('view-source:' + file.path);
// after
depends('app:file:' + encodeURIComponent(file.path));
Defensive patterns

Strategy: validation

Validate before calling

const FORBIDDEN = /^(moz-icon|view-source|jar):/;
function safeDepends(depends, dep) {
  if (FORBIDDEN.test(dep)) throw new Error(`Unsupported depends scheme: ${dep}`);
  depends(dep);
}

Type guard

function isSafeDep(dep) {
  return typeof dep === 'string' && !/^(moz-icon|view-source|jar):/.test(dep);
}

Prevention

When it happens

Trigger: Calling `depends('moz-icon:...')`, `depends('view-source:...')`, or `depends('jar:...')` inside a load function (server or universal) identified by `route_id`.

Common situations: Constructing dependency keys from user-supplied or file://-ish URLs; passing a resource URI directly instead of an app-relative key; copy-pasted identifiers from browser internals.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/dff1de9c76178bf4. Report an issue: GitHub.