Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
272 stars 54 forks source link

Update TypeShape 8.0.1 -> 9.0.0 #226

Closed Zaid-Ajaj closed 3 years ago

Zaid-Ajaj commented 3 years ago

Some weird FATAL runtime error occurs with TypeShape and it happens only on deployed application in azure (assuming it is running net5.0) but works locally just fine using either -c Debug or -c Release

Fatal error. Internal CLR error. (0x80131506) at System.RuntimeType.get_IsByRefLike() at TypeShape.Core.Core+TypeShapeImpl.resolveTypeShape(System.Type) at TypeShape.Core.Core+ShapeFSharpRecord`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor() at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean, Boolean) at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) at TypeShape.Core.Core+TypeShapeImpl.activateGeneric(System.Type, System.Type[], System.Object[]) at TypeShape.Core.Core.Activator.CreateInstanceGeneric.Static[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Core.FSharpOption`1<System.Type[]>, Microsoft.FSharp.Core.FSharpOption`1<System.Object[]>) at TypeShape.Core.Core+Shape.|FSharpRecord|_|(TypeShape) at Fable.Remoting.Server.Proxy.makeApiProxy[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Fable.Remoting.Server.RemotingOptions`2<System.__Canon,System.__Canon>) at Fable.Remoting.Giraffe.GiraffeUtil.buildFromImplementation[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.AspNetCore.Http.HttpContext,System.__Canon>, Fable.Remoting.Server.RemotingOptions`2<Microsoft.AspNetCore.Http.HttpContext,System.__Canon>) at Fable.Remoting.Giraffe.Remoting.buildHttpHandler[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Fable.Remoting.Server.RemotingOptions`2<Microsoft.AspNetCore.Http.HttpContext,System.__Canon>) at <StartupCode$Server>.$Server.main@()

So I am thinking it might have to do with TypeShape using an old reflection API so I think we should update it to latest 9.0.0 just in case. What do you think, @kerams?

kerams commented 3 years ago

That is really weird. Updating is certainly worth a shot, it won't hurt anything. However, TypeShape isn't pinned to a major version, are you sure you're not already deploying your application with v9?

Zaid-Ajaj commented 3 years ago

You are right @kerams it looks like it this is just paket lock from the SAFE template. Maybe that's the problem

kerams commented 3 years ago

https://github.com/eiriktsarpalis/TypeShape/commit/a8be8c77f0719e557b3c7ead2a62b8b23f80758b#diff-6a7780a357a197c700a5c9acdacd22efa6ea59e35cfb542b4ad370acf8766565R147-R151 This has been added in v9 and according to the call stack you're hitting the #else branch for some reason. I have no problems with it locally either (.NET 5 runtime and TypeShape 9.0.0). Maybe ask Eirik if he has any idea what's up?

In the meantime, I'm sure locking into v8 will help you.

Zaid-Ajaj commented 3 years ago

Yeah I was talking to @isaacabraham about it (he reported the issue) and I think we should either update TypeShape to 9.0.0 or set better version constraints to say TypeShape should be >= 8.0.1 && < 9.0.0 because now paket (correctly) chose the highest matching version of TypeShape because we have only >= 8.0.1

eiriktsarpalis commented 3 years ago

@Zaid-Ajaj could you share the full stacktrace?

eiriktsarpalis commented 3 years ago

Are you consuming TypeShape using the nuget package or by embedding its source file? The former only targets netstandard2.0 which uses the workaround referenced in https://github.com/eiriktsarpalis/TypeShape/commit/a8be8c77f0719e557b3c7ead2a62b8b23f80758b#diff-6a7780a357a197c700a5c9acdacd22efa6ea59e35cfb542b4ad370acf8766565R147-R151

Zaid-Ajaj commented 3 years ago

@eiriktsarpalis The stack trace was posted in TypeShape/#45. Do you recommend to use the source file or the nuget package v9?