#Elixir's language server hangs infinitely while running my code for analysis

1 messages ยท Page 1 of 1 (latest)

wary junco
#
defmodule Syphon do
  require Logger
  require OSScan

  {stream, exit_code} = OSScan.scan("127.0.0.1")

  case exit_code do
    0 -> stream
      |> Stream.each(&IO.puts/1)
      |> Stream.run()

      Logger.info("Scan succcessfuly completed")
    _ -> Logger.error("Scan failed with exit code #{exit_code}")
  end
end

I don't know if it's the right way to do this but I'm using a stream to print out the result of my nmap scans. My program hangs infinitely when I run it which is kinda fine, I'll search for tips on process management after. However, the Elixir Language Server does too which is problematic because it means I can't get any code completion/help!

Thanks for the help!
-noctis

radiant brook
#

you're doing this at compile-time instead of runtime, that's why your language server hangs, because it's trying to just compile your code and basically having the whole logic of the application run during the compile

#

you should put the logic into a function instead

wary junco
#

Aaaah thanks for the help. I was doing that like a script while it needs to be done with functions! Ok thanks!

radiant brook
#

if you want to run it as a script, remove the defmodule surrounding those lines and put it in a file ending in .exs

#

if you want to write a module with functions, then you keep the defmodule and put it in a file ending in .ex

wary junco
#

Ok thanks a lot. I love elixir this is so fun writing stuff in it

radiant brook
#

๐Ÿ‘ ๐Ÿ’ฏ

wary junco
#

How do I mark this as solved?

radiant brook
#

click the overflow menu with the three dots and go to "edit tags"

#

I did it for you ๐Ÿ˜…

wary junco
#

Ok ๐Ÿ™