purescript-contrib / purescript-affjax

An asynchronous AJAX library built using Aff.
Apache License 2.0
121 stars 78 forks source link

spago run hangs with get #150

Open yaitskov opened 4 years ago

yaitskov commented 4 years ago

Hi,

An application process using get function doesn't terminate even all activities completed i.e. there is no pending promises, set timers.

spago init
spago install affjax
npm install xhr2
module Main where

import Prelude (Unit, bind, discard, (<>))

import Effect (Effect)
import Effect.Console as EC -- (log)
import Effect.Class.Console (log)
import Affjax (get, printError)
import Data.Either (Either(..))
import Affjax.ResponseFormat (string)
import Effect.Aff (Aff, launchAff_)

my :: Aff Unit
my = do
  r <- get string "http://ya.ru"
  case r of
    Right rr -> log ("response body: " <> rr.body)
    Left e -> log ("OOPS Error " <> printError e)

main :: Effect Unit
main = do
  launchAff_ do
    my
  EC.log "HELLO"
spago build
spago run

Request body is printed but process stays alive forever. If I replace get request with simple logging then process terminates as expected.

my :: Aff Unit
my = do
  log ("HELLO" <> " " <> "WORLD")

spago version 0.15.3 affjax v10.1.0 xhr2 "0.2.0"