-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
Summary: Opening this in a separate PR but the discussion can be viewed on #4832. Basically, this is a native implementation and is a bit more elegant. The consensus on my previous PR was that it should be done natively rather than in JS. There's now no maximum valid timeout value and a timeout of 0 will never time out. ontimeout isn't implemented (yet) in this PR. cc nicklockwood ide philikon Closes #5038 Reviewed By: svcscm Differential Revision: D2838743 Pulled By: nicklockwood fb-gh-sync-id: 774f864ac35082bf522f7665f4311bd3affbe82c
- Loading branch information
There are no files selected for viewing
7 comments
on commit 1303e6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is breaking for me on master. I can't seem to track down what's going on. Everything appears to be correct. Will try again in the morning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested it from a clean react-native init
and it seems to be working fine. Unfortunately I'm having issues setting up a test with master right now and will have to wait until tomorrow to trouble shoot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christopherdro you probably have mismatched JS and Java code versions. Seems to happen quite a lot whenever we make changes to native interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running on master you need to build the Android runtime from source. Otherwise, as @nicklockwood is saying, you'll end up with incompatible JS and native modules versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicklockwood @foghina @klvs
Yea, I figured I was missing something like that. Sorry for the bother & thanks for the tip!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, I guess I want to use this! :-) And there's lots of people asking about support for timeouts in RN it seems. Are there docs about it? I currently use fetch() so I'd want it available there. I don't see it mentioned in docs tho https://facebook.github.io/react-native/docs/network.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jslz I believe that react-native used whatwg-fetch which doesn't include a timeout option (honestly always wondered why). Since the PR I authored implements the timeout api on XMLHttpRequest, any polyfill that uses it should have a working timeout. Maybe try whatwg-fetch-timout?
If I'm not mistaken, the
mClient
is a singleton instance -- wouldn't this mean that thetimeout
provided by a single request would apply the rule for the client that manages all requests from that point forward?Basically this seems that it would get applied at a global level, rather than the request level