zwilias / elm-json

Install, upgrade and uninstall Elm dependencies
MIT License
183 stars 9 forks source link

Elm-json occasionally gets stuck, particularly when called from elm-review #54

Open tsukimizake opened 1 year ago

tsukimizake commented 1 year ago

While investigating an issue with elm-review getting stuck, I discovered that the underlying cause was elm-json becoming stuck when it was called in elm-review. Specifically, the issue occurs on isahc::get(url) in the fetch_remote_versions function. Once this happens, as terminating the elm-review process does not kill the elm-json process, it continues to fail on lock.exclusive() in the fetch_versions() function until all elm-json processes are manually terminated. And even if terminated, isahc::get usually continues to fail for some reason.

When it is stuck on isahc::get, the trace is like this.

> pkill elm
...
> ~/elm-json/target/debug/elm-json -v -v -v -v solve frontend/elm.json
2023-04-12T09:48:40.545177Z DEBUG elm_json::package::retriever: Fetching versions since 0
2023-04-12T09:48:40.546279Z DEBUG agent_thread{id=0}: isahc::agent: agent took 570.513µs to start up
2023-04-12T09:48:40.547415Z TRACE agent_thread{id=0}:poll_messages:handle_message{Execute(Easy { handle: 0x7f9d98811600, handler: RequestHandler })}: isahc::agent: received message from agent handle
2023-04-12T09:48:40.599818Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false

I could successfully request https://package.elm-lang.org/all-packages/since/0 from my browser, so I'm unsure why elm-json is experiencing this problem.

Elm-review calls elm-json in this manner: /Users/tsukimizake/.elm/elm-tooling/elm-json/0.2.13/elm-json solve --extra elm/json@1 stil4m/elm-syntax@7 elm/project-metadata-utils@1 MartinSStewart/elm-serialize@1 -- /Users/tsukimizake/my-app/frontend/elm.json . The relevant code can be found here (spawnElmJsonAsync).

It appears that someone else has encountered a similar issue, as described in this post: https://elmlang.slack.com/archives/C010RT4D1PT/p1680266273643779.

Does anyone have any ideas about why this might be happening? Alternatively, could we consider implementing a timeout for the GET request to address the issue?

My environment is: macOS 12.6.5 (Intel MacBook Pro 2019) node v16.19.1