Comments (10)
I think we should improve the API with a few caveats:
- a max number of retries for reconnects that will emit an error on the client itself, so we can potentially let the application do something.
- an offline event, so that the app can do something
- make the requests error after a timeout
from undici.
Thanks for your efforts! I know these problems are hard and those kind of bugs elusive. If you’d still come and take a shot after some time, you are always welcomed!
from undici.
I think we could look at https://www.npmjs.com/package/reconnect-core for some inspiration.
from undici.
Well, I suppose the above is imprecise. While it does attempt to reconnect that isn't the heart of the issue. Rather, at the time it attempts to reconnect there are 0 callbacks in the queue for the client. Which leads to the lack of notification.
Still digging, but wanted to course correct the above line of thinking about what the core problem is.
from undici.
If you find the root cause, please send a PR!
from undici.
Got it, gonna do a quick PR and see if there any design tweaks needed with it. Thanks
from undici.
Okay, PR #12 is sent. As noted I went for what I thought would have the lowest chance of unintended consequences. That said it does feel slightly hacky. If you have thoughts on a better way to approach it I'd be glad to tackle it. Thanks
Sorry for all the noise. I'm going to work on a better solution that I feel confident doing a PR on.
from undici.
Those sound like nice enhancements that would definitely address my needs. I can take a stab at those over the next few days and see if I can come up with clean implementations of each.
from undici.
Unfortunately I haven't been successful tackling the proposed API updates. I did add a maxRetries
option in this branch. However, the tricky part is that if a client is initialized against a non-listening URL it will never be placed in kQueue
, as it will just hang in the reconnect process until maxRetries
(if set) is hit.
That being the case the callback never gets into the queue and so all affected requests will remain hung even after we emit maxRetries
and close the client.
Similarly, in that scenario it will never make it to the timer in order to execute the timeout error on the request. I've tried several methods of working around this, mostly by changing the order of operations around. For instance moving the if (!this.socket) connect(...)
into the kQueue
worker function, but this leads to other requests hanging indefinitely.
Similarly I've tried initializing the Request
, wrapping the callback, and placing it in the queue before the call to connect but that has led to various other issues.
I'm sure there is a way to do this, but unfortunately I've put a good bit of time toward trying and have failed at every turn. I'm not sure if you might want to keep this issue open for any reason, so I'll leave it open for now but feel free to close it.
from undici.
I've seen this as well, it goes into a live lock loop of reconnecting.
from undici.
Related Issues (20)
- Client not following redirects HOT 1
- Disallow force push into protected branches (main, next) HOT 3
- WebSocket performance / benchmarking
- When data is empty, WebSocket will not fire a message event. HOT 1
- Improve docs on Interceptors HOT 1
- WHATWG handling of URLs that include username:password (credentials) HOT 14
- Large number of parallel requests always result in an error HOT 2
- Content-Length header should be ignored by fetch HOT 4
- Fetching headers of small files causes node process to terminate after 8 seconds since GHSA-9f24-jqhm-jfcw HOT 1
- Implement HTTP caching HOT 9
- Only use one network request when identical requests are made HOT 6
- TypeError and Access Issues in jsdom Environment Post Update to undici 6.16.0 HOT 4
- websocket: a number of conditions fail the connection but do not emit an error event
- websocket: handle parser errors more consistently
- running autobahn test suite HOT 4
- Failing autobahn tests HOT 6
- Interceptors: add response decompress interceptor HOT 4
- Implement Request/Response `.bytes()` method
- permessage-deflate support in websocket HOT 1
- Optimization of websocket masking HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from undici.