dotnet/runtime · error · Error

Invalid config, resources is not set

Error message

Invalid config, resources is not set

What it means

Thrown inside loadJSModule (loader/assets.ts) after the loader tried to resolve a URL via locateFile(asset.name) but asset.resolvedUrl is still falsy. This means the JS-module asset (native/runtime/diagnostics module) has neither a pre-resolved URL nor a name the loader can turn into one, so the dynamic import() target is unknown.

Source

Thrown at src/native/libs/Common/JavaScript/loader/assets.ts:64

    let mod: JsModuleExports = await asset.moduleExports;
    if (mod) {
        asset.moduleExports = mod;
    }
    totalAssetsToDownload++;
    if (!mod) {
        if (assetInternal.name && !asset.resolvedUrl) {
            asset.resolvedUrl = locateFile(assetInternal.name, true);
        }
        assetInternal.behavior = "js-module-dotnet";
        if (typeof loadBootResourceCallback === "function") {
            const blazorType = behaviorToBlazorAssetTypeMap[assetInternal.behavior];
            dotnetAssert.check(blazorType, `Unsupported asset behavior: ${assetInternal.behavior}`);
            const customLoadResult = loadBootResourceCallback(blazorType, assetInternal.name, asset.resolvedUrl!, assetInternal.hash ?? "", assetInternal.behavior);
            dotnetAssert.check(typeof customLoadResult === "string", "loadBootResourceCallback for JS modules must return string URL");
            asset.resolvedUrl = makeURLAbsoluteWithApplicationBase(customLoadResult);
        }

        if (!asset.resolvedUrl) throw new Error("Invalid config, resources is not set");
        mod = await import(/* webpackIgnore: true */ asset.resolvedUrl);
        asset.moduleExports = mod;
    }
    onDownloadedAsset(assetInternal);
    return mod;
}

export async function callLibraryInitializerOnRuntimeConfigLoaded(asset: JsAsset): Promise<any> {
    const module = await loadJSModule(asset);
    const name = asset.name || asset.resolvedUrl || "unknown";
    try {
        if (typeof module.onRuntimeConfigLoaded === "function") {
            await module.onRuntimeConfigLoaded(loaderConfig);
        }
        return module;
    } catch (err) {
        const message = err instanceof Error ? err.message : String(err);
        throw new Error(`Failed to invoke 'onRuntimeConfigLoaded' on library initializer '${name}': ${message}`, { cause: err });

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Inspect loaderConfig.resources.jsModule* entries and ensure every asset has either a non-empty name or a resolvedUrl.
  2. Republish the project to regenerate a well-formed boot config.
  3. If injecting custom JS module assets programmatically, set both name and resolvedUrl explicitly.
  4. Check that a loadBootResourceCallback (withResourceLoader) is not returning undefined for dotnetjs resources.

Example fix

// before
resources.jsModuleRuntime = [{ }];

// after
resources.jsModuleRuntime = [{ name: 'dotnet.runtime.js', resolvedUrl: '/_framework/dotnet.runtime.js' }];
Defensive patterns

Strategy: validation

Validate before calling

// Validate every JS-module asset has a resolvable URL
for (const m of [...(cfg.resources?.jsModuleNative ?? []), ...(cfg.resources?.jsModuleRuntime ?? [])]) {
  if (!m.resolvedUrl && !m.name) throw new Error(`JS module asset missing name and resolvedUrl`);
}

Type guard

function isResolvableJsAsset(a: any): a is { name: string; resolvedUrl?: string } {
  return typeof a?.name === 'string' && a.name.length > 0
      || typeof a?.resolvedUrl === 'string';
}

Prevention

When it happens

Trigger: resources.jsModuleNative / jsModuleRuntime / jsModuleDiagnostics / modulesAfterConfigLoaded contains an entry with both resolvedUrl and name unset/empty. locateFile only runs when asset.name is truthy; if name is empty, resolvedUrl stays undefined and this throws.

Common situations: Hand-edited boot config where a JS module asset object is empty {}; a custom resource loader (loadBootResourceCallback) returned undefined and cleared resolvedUrl; corrupted publish output where jsModuleRuntime[0] lost its name field.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/24779595b0250ee4. Report an issue: GitHub.