Skip to content
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

http_server ; http_open server hangs, no response after pulling some updates #2470

Open
Zandrenel opened this issue Aug 7, 2024 · 2 comments

Comments

@Zandrenel
Copy link

I had a http_server I was working on, it was working except its process would get the req then hang if I tried to make a http_open call in the request, the http_open call at the time worked separetely and the http_server worked perfectly fine except in that instance. I tried to update scryer-prolog + my system and since then a simple GET req to / on a http_server hangs and never returns response, same was true locally and tested on a separate computer running windows with a fresh scryer-prolog build.

Example of the steps I can take to recreate:

file contents, test.pl

:- use_module(library(http/http_server)).
:- use_module(library(http/http_open)).
:- use_module(library(charsio)).


server(Port) :-
    http_listen(Port, [
                    get(/, root_handler),
		    get(test, root_handler2)
		]).

root_handler(_Request, Response):-
    write(1),
    http_status_code(Response, 200),
    write(2),
    http_body(Response, text("Hello!")),
    write(3).

root_handler2(_Request, Response):-
    write(1),
    test_get(HTML),
    write(5),
    http_body(Response, text(HTML)),
    write(6).

test_get(Text):-
    write(2),
    http_open("https://github.com/mthom/scryer-prolog", S, [method(get)]),
    write(3),
    get_n_chars(S, 10, Text),
    close(S),
    write(4).

$ scryer-prolog test.pl
?- server(3000).
Listening at 0.0.0.0:3000
next sending $ curl localhost:3000 results in no response ever reaching curl and the output

2024-08-07 (19:10:16) get /
123

from prolog, also closing the terminal is impossible unless forcefully

test 2:

?- test_get(X).
234   X = "\n\n\n\n\n\n\n<!D".
?- 

test 3:

?- server(3000).
Listening at 0.0.0.0:3000
2024-08-07 (19:17:25) get /test
12

so in test 1 it just never returns, in 2 it is fine with just the open, in 3 it never gets past the open. at the very least test 1 was working 2 weeks ago before i updated.

@aarroyoc
Copy link
Contributor

aarroyoc commented Aug 8, 2024

I think some dependencies were upgraded this week, which might have lead to that regression.

However I don't think rolling back to an older version is a real fix. I've been working on a plugin interface. Once it's done, this predicates will be implemented using that interface. Current approach requires many moving parts and it's not a good fit.

@Zandrenel
Copy link
Author

If there's anything that can be done to assist with that I'd be interested, otherwise that sounds good and I hope that it goes well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants