Closed dicej closed 2 weeks ago
NB: I left out an important step above when I first opened the issue and just edited it in: "Comment out this line in the example source code."
@SingleAccretion helped narrow this down and find a solution. Turns out some of the warnings I was ignoring were important, and I needed <EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
, which I had read about, but ignored because it's supposedly implied by <PublishTrimmed>true</PublishTrimmed>
. Turns out that's not always the case. See the discussion following https://discord.com/channels/143867839282020352/1141126727028985877/1278474370842628116 for details.
I've been developing an AspNetCore example based on wasi-http. One of the URI handlers in that example uses
System.Text.Json.Serialization
and source generation to deserialize request bodies. When built using-c Debug
, it all works fine. However, the-c Release
build is incorrect, having replaced the code for deserializing a customclass
with an infinite loop.I've tried to reduce the issue to a minimal reproduction, e.g. as a CLI app with a
Main
method, but so far I've only managed to reproduce this issue in anAspNetCore
web server. To reproduce:spin build -u
command with e.g.dotnet publish -o build App.csproj -c Release && wasmtime serve -O pooling-table-elements=60000 -O pooling-max-core-instance-size=2000000 -S cli --dir static::/ build/App.wasm
curl -i localhost:8080/data -H 'content-type: application/json' -d '{"Greeting":"Hola"}'
to send a request to the problematic endpoint and note that the server loops forever without returning a response.wasm-tools print build/App.wasm | less
to examine the Wasm file and search forApp_SpinHttpWorld_wit_exports_wasi_http_v0_2_0_AppJsonSerializerContext__global__System_Text_Json_Serialization_Metadata_IJsonTypeInfoResolver_GetTypeInfo
, noting the infinite loop generated by the compiler. Compare that with the correct, expected code.Apologies for the complicated steps to reproduce this. Let me know if you have any trouble following them.