braidjs icon indicating copy to clipboard operation
braidjs copied to clipboard

Not able to run the demo

Open thhck opened this issue 1 year ago • 14 comments

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/

thhck avatar May 09 '24 13:05 thhck

Oh, interesting! Checking it out ...

toomim avatar May 09 '24 15:05 toomim

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

toomim avatar May 09 '24 15:05 toomim

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.

toomim avatar May 09 '24 16:05 toomim

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 ?

thhck avatar May 09 '24 20:05 thhck

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 avatar May 11 '24 11:05 toomim

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

toomim avatar May 11 '24 12:05 toomim

It looks like this is why the demo was failing: https://github.com/spdy-http2/node-spdy/issues/380

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

toomim avatar May 11 '24 12:05 toomim

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.)

toomim avatar May 11 '24 19:05 toomim

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

thhck avatar May 14 '24 19:05 thhck

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!

toomim avatar May 14 '24 19:05 toomim

Was able to run the blog demo on braid-http/demos/blog :+1:
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 ?

thhck avatar May 30 '24 15:05 thhck

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 avatar May 30 '24 21:05 toomim

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:

  • https://github.com/braid-org/braidmail
  • https://mail.braid.org

toomim avatar May 30 '24 21:05 toomim

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 avatar May 31 '24 10:05 toomim