Closed jasontwuk closed 5 years ago
The crude implementation of networking in the code doesn't prevent duplicate messages, so when a request times out due to the simulated unpredictable network speed, the message might get sent again even though the original message is also still in flight. This is expected. I've adjusted the code a bit in attached patch so that this happens less often.
In node.js, you should give the network a moment to propagate routes before you try to run routeRequest
(for example by wrapping your code in a setTimeout
call).
Thank you very much.
Hi, I think the example's outcome in this section is a bit strange. https://eloquentjavascript.net/11_async.html#p_2KFj5q8DUa
If you use the "Run code" function to run the code, it will print out the result several times (one time, two times or sometimes three times). Is it supposed to print its result more once?
Also, I have tried to run this code in Node.js, it threw the following error message:
But if you change the target in routeRequest function from "Church Tower" to "Cow Pasture", "Butcher Shop" or "Gilles' Garden", the code works fine. It seems like it only can pass the message to its next door neighbours.