-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack overflow when deserialising int64 #47
Comments
Given it's a copy (albeit older) of the one in Fable, I searched there. Surprised it didn't come up when googling earlier! It's almost certainly this issue. I guess the converter here could be updated to match the Fable version? I'm not sure if there are any changes specific to Remoting, however. |
@csmager thanks a lot for tracking this down, it seems to be that the custom converter needs an update to match what Fable is doing at the moment. BTW are you using Fable 2.0 or Fable 1.x ? I am trying to reproduce the issue with tests in this PR, I was unable to run the integration tests on my new windows box so I will let travis handle the work for me 😄
That's the plan, there is actually (so far) no specific changes for the fork of the converter, it is just that I thought that I can customize it whenever necessary |
I'm using Fable 1.x. I too struggled to get the integration tests to run - either on Windows or macOS. The specific trigger for this was actually a single case union with a long - something like type SingleCase = SingleCase of int64 It was only later I discovered that the deserialisation results in a stack overflow for any conversion to int64 with invalid / unsupported content. It may be the javascript end only creates the wrong representation when part of a similar union. I can check it out tomorrow. So I think there are two issues here:
|
Yes, I finally broke the tests 😄 All these tests run without issue: QUnit.testCaseAsync "IServer.echoPrimitiveLong" <| fun test ->
async {
let! fstResult = server.echoPrimitiveLong (20L)
let! sndResult = server.echoPrimitiveLong 0L
let! thirdResult = server.echoPrimitiveLong -20L
do test.equal true (fstResult = 20L)
do test.equal true (sndResult = 0L)
do test.equal true (thirdResult = -20L)
}
QUnit.testCaseAsync "IServer.echoComplexLong" <| fun test ->
async {
let input = { Value = 20L; OtherValue = 10 }
let! output = server.echoComplexLong input
do test.equal true (input = output)
}
QUnit.testCaseAsync "IServer.echoOptionalLong" <| fun test ->
async {
let! fstResult = server.echoOptionalLong (Some 20L)
let! sndResult = server.echoOptionalLong None
do test.equal true (fstResult = (Some 20L))
do test.equal true (sndResult = None)
} but after the one with the single union case, I get the stackoverflow exception: QUnit.testCaseAsync "IServer.echoSingleDULong" <| fun test ->
async {
let! output = server.echoSingleDULong (SingleLongCase 20L)
do test.equal true (output = (SingleLongCase 20L))
} Now I have something to work with |
Can you please elaborate on what errors you got on both machines? on macOS it should have been as simple as
Do you have a concrete example of such JSON so that I can add a test for it? |
Yep, I'll run these again tomorrow and report back.
This was essentially what was in my initial post, though it seems we've now narrowed the 'circumstances' to at least include a single case DU. When serialising that I would see this sort of representation in the browser dev tools for the failed request: { "SingleCase": {low: 5, high: 0, unsigned: false} } And when you combine that with the bug in the deserialiser it means you get a stack overflow for these sort of requests. |
Could we use the |
Just updating the code should be fine, the problem here seems to with the updated Tests Failed:
[
{
"module": "Fable.Remoting",
"name": "IServer.echoSingleDULong",
"result": false,
"message": "Test timed out",
"actual": null,
"expected": null,
"testId": "54831a87",
"negative": false,
"runtime": 5001,
"todo": false,
"source": "internalStop/config.timeout<@https://code.jquery.com/qunit/qunit-2.3.2.js:1930:6"
}
] I will investigate this even more at the converter level, if converter round trip tests pass, then the problem must be with the serialization on the client |
I think we can confirm this is a Fable issue now (after updating the converter) not serializing open Fable.Core
open Fable.Core.JsInterop
type SingleCase = SingleCase of int64
let input = SingleCase 20L
printfn "%A" (ofJson<SingleCase> (toJson input)) error:
On the server I get the following error when I try to deserialize the data:
|
That makes sense. Fixing the converter here at least makes it easier to see where the problem is. Hopefully the related Fable client-side issue can be fixed at some point. |
Re the integration tests, I'm fumbling in the dark a bit. I assume from the logging of 'Starting FireFox driver' that I need FireFox, so I've installed it. These are the results I get: macOS
WindowsNPM fails to download the Running
|
Updating to the latest |
@csmager Thanks for the repro! In the Long serialization PR, I did both things too, I removed the node-sass dependency (I have no idea why it was there 😂) and updated the latest windows geckodriver. |
Fixed and merged. published nuget packages should be available soon, can you please update and confirm the that it is fixed? |
@Zaid-Ajaj sorry it's taken a few days, I've only just got back to what I was working on previously. I reverted the workaround I had and it all seems to work now. Thanks! |
Awesome! thanks for the reporting back 😄 I will close this issue, please let me know if it persists in some other weird edge case |
This is a remarkably simple repro, but it took a long time to track down. I'd set up some endpoints and one kept killing the server process with
StackOverflowException
with no hint of what or where it was failing.It turns out (possibly a separate issue) that the client will serialise a long / int64 like this:
And deserialising this using
Fable.Remoting.Json.FableJsonConverter
will result in aStackOverflowException
.I've put together a small repro contrasting the behaviour of the converter here and the one in
Fable.JsonConverter
. The last 3 all cause the same issue.The output is
I've tried (briefly) to work out where this is broken, but I've run out of time today.
The text was updated successfully, but these errors were encountered: