Skip to content

Commit bffd5a3

Browse files
kb(deployment): failed to compile, expected magic word
1 parent 43fe166 commit bffd5a3

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
40.5 KB
Loading

knowledge-base/wasm-magic-word.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Failed to execute compile on WebAssembly - expected magic word 00 61 73 6d
3+
description: WASM Compile Error When Hosted - expected magic word and fail to execute compile
4+
type: troubleshooting
5+
page_title: WASM Compile Error When Hosted - expected magic word 00 61 73 6d
6+
slug: common-kb-wasm-magic-word
7+
position:
8+
tags:
9+
ticketid: 1451701
10+
res_type: kb
11+
---
12+
13+
## Environment
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Hosting</td>
18+
<td>cloudflare.com integration with smarterasp.net, may affect others</td>
19+
</tr>
20+
<tr>
21+
<td>Environment</td>
22+
<td>WASM Blazor app</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
28+
## Description
29+
Publishing a client-side (WASM) Blazor app may fail with messages similar to the error below.
30+
31+
A particular environment is an ASP.NET Core hosted Blazor project hosted on smarterAsp.net with the automatic config which enabled caching and compacting with cloudflare.com.
32+
33+
34+
35+
## Error Message
36+
* WASM: wasm streaming compile failed: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'
37+
* WASM: failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found ef bb bf 3c @+0
38+
* CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found ef bb bf 3c @+0
39+
40+
![failed to compile expected magic word](images/wasm-fail-to-compile-magic-word.png)
41+
42+
## Cause\Possible Cause(s)
43+
The errors indicate the following issues:
44+
45+
* The MIME type for the `wasm` files is wrong - it must be `application/wasm` but the hosting environment used the wrong one
46+
* The wasm file is broken (for example, archived, compressed twice or otherwise truncated/modified).
47+
48+
## Solution
49+
The general solution is to make sure that the application files are not tampered with and that you have the correct server settings as per Microsoft's documentation: [https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/blazor/webassembly?view=aspnetcore-3.1](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/blazor/webassembly?view=aspnetcore-3.1)
50+
51+
In the particular smarterasp.net hosting case, disabling the cloudflare integration resolved the issue.

0 commit comments

Comments
 (0)