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

Not able to run the demo #24

Closed
thhck opened this issue May 9, 2024 · 14 comments
Closed

Not able to run the demo #24

thhck opened this issue May 9, 2024 · 14 comments

Comments

@thhck
Copy link

thhck commented May 9, 2024

Hello,

I was not able to run the demo from braid-http/demos/chat
is it up to date ?
I had to edit server.js +19 to var braidify = require('../blog3/braidify-server')
and even after that I got:
GET https://localhost:3009/chat net::ERR_CONNECTION_REFUSED errors in the console when browsing https://localhost:3009/

@toomim
Copy link
Member

toomim commented May 9, 2024

Oh, interesting! Checking it out ...

@toomim
Copy link
Member

toomim commented May 9, 2024

Some of this code is definitely out-of-date. I'm updating it now.

@toomim
Copy link
Member

toomim commented May 9, 2024

This code is very out-of-date. I'm working on fixing it, but in the meantime, I'd work from the examples at https://www.npmjs.com/package/braid-http and the test server inside the test/ folder.

@thhck
Copy link
Author

thhck commented May 9, 2024

from examples at https://www.npmjs.com/package/braid-http

Do you mean the example in the readme ?

Because I was not able to make them work, but maybe it because of a lack of understanding of braid. I could give it another try after digging more into braid's documentation.

and the test server inside the test/ folder.

I was able to make it run, but http://localhost:9000 give me mostly red screen , but ( like 1 out of 8 time ) sometime a green screen. Is this expected behavior ?

@toomim
Copy link
Member

toomim commented May 11, 2024

Yes, I did mean the examples in the readme.

I am surprised that they, and the test/ server, are not working for you. Let's try to debug this 1-1! I'll send you an email.

@toomim
Copy link
Member

toomim commented May 11, 2024

I've updated the demo, and renamed it to demos/blog instead of blog3. It's functioning for me now.

@toomim
Copy link
Member

toomim commented May 11, 2024

It looks like this is why the demo was failing:
spdy-http2/node-spdy#380

The spdy library stopped working on node v15. I switched the demo to use http2-express-bridge instead.

@toomim
Copy link
Member

toomim commented May 11, 2024

I was able to make it run, but http://localhost:9000 give me mostly red screen

Can you copy and paste the section under "Our Results" into here from one of the red runs? (Note that I just renamed it to "Your Server's Responses" in master to be clearer.)

@thhck
Copy link
Author

thhck commented May 14, 2024

Without the latest change, that was the result I was having:

Failed! :(
Our Results

Read 1 {"version":["test"],"parents":["oldie"],"body":"{\"this\":\"stuff\"}"}!
Read 1 {"version":["test1"],"parents":["oldie","goodie"],"patches":[{"unit":"json","range":"[1]","content":"1"}],"extra_headers":{"hash":"42"}}!
Read 1 {"version":["test2"],"patches":[{"unit":"json","range":"[2]","content":"2"}]}!
Read 1 {"version":["test3"],"patches":[{"unit":"json","range":"[3]","content":"3","extra_headers":{"hash":"43"}},{"unit":"json","range":"[4]","content":"4"}]}!
Read 3 {"version":["test"],"parents":["oldie"],"body":"{\"this\":\"stuff\"}"}!
Read 2 {"version":["test"],"parents":["oldie"],"body":"{\"this\":\"stuff\"}"}!
Read 2 {"version":["test1"],"parents":["oldie","goodie"],"patches":[{"unit":"json","range":"[1]","content":"1"}],"extra_headers":{"hash":"42"}}!
Read 2 {"version":["test2"],"patches":[{"unit":"json","range":"[2]","content":"2"}]}!
Read 2 {"version":["test3"],"patches":[{"unit":"json","range":"[3]","content":"3","extra_headers":{"hash":"43"}},{"unit":"json","range":"[4]","content":"4"}]}!
Write test 1 returned 200
Write test 2 returned 200
Write test 3 returned 200
Write test 4 returned 200
Read 3 {"version":["another!"],"body":"\"!\""}!
Read 1 {"version":["another!"],"body":"\"!\""}!
Read 2 {"version":["another!"],"body":"\"!\""}!

Known Results

Read 1 {"version":["test"],"parents":["oldie"],"body":"{\"this\":\"stuff\"}"}!
Read 1 {"version":["test1"],"parents":["oldie","goodie"],"patches":[{"unit":"json","range":"[1]","content":"1"}],"extra_headers":{"hash":"42"}}!
Read 1 {"version":["test2"],"patches":[{"unit":"json","range":"[2]","content":"2"}]}!
Read 1 {"version":["test3"],"patches":[{"unit":"json","range":"[3]","content":"3","extra_headers":{"hash":"43"}},{"unit":"json","range":"[4]","content":"4"}]}!
Read 2 {"version":["test"],"parents":["oldie"],"body":"{\"this\":\"stuff\"}"}!
Read 2 {"version":["test1"],"parents":["oldie","goodie"],"patches":[{"unit":"json","range":"[1]","content":"1"}],"extra_headers":{"hash":"42"}}!
Read 2 {"version":["test2"],"patches":[{"unit":"json","range":"[2]","content":"2"}]}!
Read 2 {"version":["test3"],"patches":[{"unit":"json","range":"[3]","content":"3","extra_headers":{"hash":"43"}},{"unit":"json","range":"[4]","content":"4"}]}!
Read 3 {"version":["test"],"parents":["oldie"],"body":"{\"this\":\"stuff\"}"}!
Write test 1 returned 200
Write test 2 returned 200
Write test 3 returned 200
Write test 4 returned 200
Read 1 {"version":["another!"],"body":"\"!\""}!
Read 2 {"version":["another!"],"body":"\"!\""}!
Read 3 {"version":["another!"],"body":"\"!\""}!

From firefox

However, use google's chromium I had 100% green pages

@toomim
Copy link
Member

toomim commented May 14, 2024

Ohhh... I haven't tested Firefox for a bit! I'll get on that.

It looks like the only difference is the ordering of the events:
image

So no worries— it's working! Firefox is known to do some buffering on the streams returned from fetch(). We actually detect firefox in the braid-http server and send it extra blank lines after updates in order to force it to flush its cache and return the event to the client. It's possible that this buffering is causing some of the reads to be delayed, which might make them arrive out-of-order. I'll look into it so that we don't get scary test failure messages. :-P

Thanks for providing this test-case!

@thhck
Copy link
Author

thhck commented May 30, 2024

Was able to run the blog demo on braid-http/demos/blog 👍
However I'm still having a bug with the chat demo.

In server.js , seems that the file doesn't exist line 16:
var braidify = require('../../braidify-server')

Should this be var braidify = require('../../braid-http-server.js') instead ?

@toomim
Copy link
Member

toomim commented May 30, 2024

Ah, yes I haven't updated the chat demo — that looks right!

There might be other changes necessary to get it up to speed too... digging in...

@toomim
Copy link
Member

toomim commented May 30, 2024

BTW, these demos are poorly named — the difference is that the "blog" fetches an index of posts, and then each individual post separately, whereas the "chat" fetches an array of all the post data.

You might also check out the braidmail repo, which is an elaboration of the "blog" approach:

@toomim
Copy link
Member

toomim commented May 31, 2024

I've fixed the chat demo. I'm sorry for allowing broken code to lay around. Thank you for bringing it to our attention!

@toomim toomim closed this as completed Sep 13, 2024
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