Nhowka / Elmish.Bridge

Create client-server Fable-Elmish apps keeping a single mindset
MIT License
138 stars 17 forks source link

Fable.SimpleJson stringify error in Bridge.Sender #35

Closed pkese closed 3 years ago

pkese commented 3 years ago

Cmd.bridgeSend appears to trigger a runtime error:

image

I have published a repo that makes bug reproducible at: https://github.com/pkese/Elmish.Bridge.Test

To run:

  Shell tab ./Elmish.Bridge.Test
 -------------------------------------- --------------------------------------
  > cd server                            > cd client
  > dotnet restore                       > npm install
  > dotnet run                           > ./run.sh

While processing Welcome message it fails to serialize Cmd.bridgeSend UpstreamMsg.GetState

pkese commented 3 years ago

In case you're wondering what the hell I was doing in server/Program.fs:
(the bug not related to that).

I'm trying to fiddle with some hardware on a Raspberry PI
and there's some impedance mismatch with Elmish.Bridge, because

So I somehow hacked a way to get dispatch from Global app and then I proxy client messages to global app using this stolen dispatch.
In the other direction I'm using Hub to dispatch state to all connected clients.

... I'm not sure how to better express that.
Inside the Bridge Hub, there probably is some similar "global singleton" state & logic, but unfortunately I can't plug into that.

Zaid-Ajaj commented 3 years ago

Fable 3 should use Json.serialize instead of JSON.stringify

Nhowka commented 3 years ago

Thanks, @Zaid-Ajaj! I'll replace it with serialize and upload a new package in a moment

Nhowka commented 3 years ago

The rc-3 version should be listed in a moment. Can you check if that fixes the issue, @pkese?

Zaid-Ajaj commented 3 years ago

@Nhowka please also add an Exclude="*.fs.js" to your Fable client package. See tempting client for reference

pkese commented 3 years ago

@Nhowka yes, now it works like a charm.
Thanks for the update.

Nhowka commented 3 years ago

@Nhowka please also add an Exclude="*.fs.js" to your Fable client package. See tempting client for reference

@Zaid-Ajaj, I saw that in Feliz there is also an inclusion for *.js, should I need to add it? Should I need to exclude the *.fs.js files if I don't have an include for *.js?

pkese commented 3 years ago

... oh and I've noticed that I was testing with an old Elmish.Bridge.Client when I found that bug (apparently I only upgraded the server side Elmish.Bridge.Giraffe to 5.0.0-rc2 but not the client).
So now it works with 5.0.0-rc3, but I never really tested the client with 5.0.0-rc2.

I hope it wasn't a bogus bug report all along.

Zaid-Ajaj commented 3 years ago

@Nhowka Feliz only includes .js files because it uses a couple of them for interop. The idea behind excluding .fs.js file is because users get weird issues where the source files of your package aren't being compiled

Nhowka commented 3 years ago

@Zaid-Ajaj I added for the next version, it's harmless and it could prevent disaster. 😗

@pkese I was testing with BridgeChat and it was working, but I probably should be using serialize anyway! 😅

Zaid-Ajaj commented 3 years ago

@pkese just in case, try dotnet fable clean --yes before restarting the application to delete build artifacts