Fable: --port free throws exception

Created on 24 May 2017  路  10Comments  路  Source: fable-compiler/Fable

Description

Supplying --port free (as per help output) throws an exception.

Unhandled Exception: System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at Microsoft.FSharp.Core.LanguagePrimitives.ParseInt32(String s)
   at Fable.Tools.Main.parseArguments(String[] args)
   at Fable.Tools.Main.main(String[] argv)

Related information

  • fable-compiler version: 1.0.4
  • fable-core version: 1.0.4
  • Operating system: OSX
bug

All 10 comments

Alright, I think the problem was here:

let tryFindArgValue key (args: string[]) =
      match args |> Array.tryFindIndex ((=) key) with
      | Some i -> Some args.[i]
      | None -> None

which should be (I committed it by mistake, not tested)

     let tryFindArgValue key (args: string[]) =
         match args |> Array.tryFindIndex ((=) key) with
        // i is the index of the key
        // i + 1 is the index of arg value
        | Some i -> 
            // if args.[i] is the last element
            if args.Length = i + 1 
            then None 
            else Some args.[i + 1] 
         | None -> None

Nice catch @Zaid-Ajaj! Could you please send a PR to fix it?

@alfonsogarciacaro Sure thing!

I have published 1.0.5 with the fix, thanks again @Zaid-Ajaj

Wouldn't it be a good idea to add a unit test to avoid regressions again?

It is! Are you volunteering? :wink:

While doing random programming things is way funner than writing master thesis, I still should keep on track for the last few weeks :P

Fix was published, I will close this for now, re-open if issue persists

So, the exception is gone, but now the switch doesn't seem to do anything ^^

/Users/alxandr/hub/Fable.Ava/dotnetsdk/dotnet fable node-run --port free "/Users/alxandr/hub/Fable.Ava/build.js"
Cannot start server, please check the port 61225 is free: Address already in use

Ah, sorry, my bad. I had to put it after the js file name.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  路  57Comments

alfonsogarciacaro picture alfonsogarciacaro  路  37Comments

bilkusg picture bilkusg  路  28Comments

sergey-tihon picture sergey-tihon  路  70Comments

chrisvanderpennen picture chrisvanderpennen  路  31Comments