Skip to content

Breaking change in WebAssembly loadBootResource #89766

Closed
@SteveSandersonMS

Description

@SteveSandersonMS

The change in PR #89435 (merged a few days ago) appears not to be back-compatible and is probably causing the SDK ingestion dotnet/aspnetcore#49704 to fail.

Specifically, when calling the application's loadBootResource callback, it now passes different values for the type parameter, and imposes new rules that are stricter than we had in the past. Existing applications' loadBootResource implementations may not support these new types/rules.

As a concrete example, see the Blazor docs at https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-7.0. This page contains the following code sample:

<script src="_framework/blazor.webassembly.js" autostart="false"></script>
<script>
  Blazor.start({
    loadBootResource: function (type, name, defaultUri, integrity) {
      if (type == 'dotnetjs') {
        return null;
      } else {
        return fetch(defaultUri, {
          cache: 'no-cache',
          integrity: integrity,
          headers: { 'Custom-Header': 'Custom Value' }
        });
      }
    }
  });
</script>

This works with 7.0, but will break after PR #89435 because the runtime now supplies the new type name js-module-runtime, which is not a documented type. The logic above will perform a fetch request for the resource, since the only documented type that can't be fetched is dotnetjs. Then the runtime will reject the value, giving the exception message For a js-module-runtime resource, custom loaders must supply a URI string. This is one of the build failures at https://github.com/dotnet/aspnetcore/runs/15504558324

Proposed resolution

For any resource type that you don't accept a Promise<Response> value, use the type name dotnetjs for back-compat. Avoid adding new type names that impose stricter rules than existed before.

cc @pavelsavara @maraf @lewing

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions