Check if push is successful - angularfire2 - error-handling

currently i develop an Ionic2 application which commuicates with a Firebase database. While updating a node sometimes it works and sometimes it doesn't.
So i tired to handle the error with the following code:
this.db.list("/Events/" + this.eventID+ "/teilnehmer").push(this.userID)
.then(resolve => {
console.log('success');
}, reject => {
console.log('error');
})
.catch(reject => {
console.log('catch');
});
But even if i disconnect my internet connection there is no error thrown.
Does someone of you know how i could handle an error if the push was not successful?

I had the same situation that push does not return promises sometime, so i raised issue on github FirebaseListObservable push() takes too long to add but unfortunately it was not resolved, I contacted firebase support through email, the support team reviewed my issue and checked the code i sent, and replied there is nothing to do in the code , and advised me to clear the phone's storage cache, i did the same and issue got resolved,
here is the mail from firebase support
Hi xxxx,
I suggest that you try clearing your phone's cache before proceeding
again, its memory might be too high. To do this, go to: Settings ->
Storage -> Cached Data. Select it then then choose ok (for clearing
the cache). Also please check this the same issue raised on Github
and answered by one of our engineers.
If the issue persists after trying the proposed suggestions, please
get back to me with a minimal and runnable code that we can use to
simulate this, possibly a plunkr or jsfiddle code, or a from the
scratch code that can demonstrate the issue.
Regards, xxxx

If you would like to handle this you could consider setting a timeout because the Promise will just stay in 'pending' if Firebase doesn't return anything and resolve, reject / catch will never be triggered.
You could do this for example with Promise.race(): Example Promise timeout with Promise.race() also check this thread: More Examples

Related

How do I troubleshoot this api call?

I have the following code...
async function GetFirstAssessment() {
try {
const response = await axios.get('http://192.168.254.10/App/GetFirstAssessment/');
return response.data;
} catch (error) {
alert('error: ' + error);
console.error(error);
}
};
It's been working fine for some time, but suddenly it no longer works and eventually times out. Or I don't even know if it "times out" since I believe the default timeout for axios is 0 but eventually it does error with the message "Error: Network Error". I've also added a picture of the stack trace but I don't think it's helpful.
I can put the url in a browser and it returns the json I'm expecting, so the problem is definitely not on the server side. I am testing from an android device connected via usb and developing with cli (not expo).
If there is any other information I can provide please let me know... not sure what to do next because this really makes no sense. I would wonder if it was a security issue except that it was working perfectly earlier. Also I have updated some other code that calls this, but even after reverting I still have the same problem... and seeing as how it is making it to the catch, I don't see how any other code could be affecting this.
I did just install the standalone react native debugger. I believe it has worked since I installed it, though I'm not 100% certain on that. Still doesn't work after closing it.
I set a break point in the server code on the first line of the api method, but it doesn't get hit. Not sure how to troubleshoot further up the chain though. I also just thought to check fiddler and it doesn't show any request coming in, though I honestly don't know if it should normally or not.

Failure to register a OneDrive file handler

I have been attempting to register a OneDrive File Handler as demonstrated on GitHub.
My initial PUT seems to work but I get very flaky results when I attempt to update. I have one domain where the handler works fine but another where I get these problems:
refresh works first time but not subsequently
refresh seems to work but handler not evident in OneDrive
change and update handler but changes not seen when I refresh
Is there any way to work out what is going on? The responses I get in Postman indicate that everything has worked but the file handler is not working.
Here are some observations which may help anyone else who stumbles on this:
the forceRefresh requests seems very patchy, I can make a change in the handler manifest and only some hours later will forceRefresh actually return the changed manifest
don't make the silly mistake I did and change the version in the handler manifest to something other than 2. If you do this the manifest will upload successfully but your handler will never appear. An error response would be much nicer than a silent fail.
I often find that even once forceRefresh has worked the new handler does not appear in my browser. To fix this I go to Local Storage (in the browser dev tools) and remove the entry for 'fileHandlerCache', then do a refresh.
BTW, handlers seem like a great way to extend OneDrive but I have found the developer experience to be pretty rough. Any chance of a smoother ride?

expo-in-app-purchases `connectAsync` not resolving for App Store reviewers

We have a react-native app to which we have just added in-app purchases using the expo-in-app-purchases package. Everything seems to be working when testing development builds and TestFlight-distributed release builds on our own devices.
However, we find that the app is consistently not working when reviewed by App Store reviewers.
In the latest review, via our error logging mechanism we discovered that the following error was thrown:
"Must wait for promise to resolve before recalling function."
This was thrown because during review the reviewer caused the following code to be executed twice, 7 minutes apart:
import { getProductsAsync } from 'expo-in-app-purchases';
...
const { responseCode, results } = await getProductsAsync(iOSProductIdArray));
It turns out the initial call to getProductsAsync never resolved, meaning when we called it again, some logic in expo-in-app-purchases (linked above) threw an error.
But what we don't know is why that method doesn't resolve when Apple reviewers use our app, when it always works when we do. The reviewers are signing in to the iTunes Store using the same sandbox credentials we use, and using the same build that we use, but are never able to load product details, which means they can never view purchase options in-app.
Is there something special about the review environment that prevents this function from working? We have theorised that InAppPurchases.connectAsync(), which we call when the app first boots, is failing for reviewers, but we have no idea how or why. Does anyone know how the review environment or process could cause this?

chrome.downloads.onCreated bug causing the function to loop through all prior downloads

When using the chrome.downloads.onCreated function, the callback function provided is being called repeatedly with all downloads in the users download history which can be found at chrome://downloads/. Based off documentation (and common sense) this should only fire once when a new download is created.
I have searched extensively about this issue and have come across one short thread from 2014. I am not sure how to reproduce the issue as it happens infrequently or what the best way to solve it is.
chrome.downloads.onCreated.addListener(download => {
console.log("GOT DOWNLOAD");
href = download.finalUrl;
message = {message: "businessHref",href: href};
messageContentScript(message);
});

Can React-Native [TypeError: Network request failed] mean internet connection failure or RN fetch timeout?

Sorry I've gone through every stack overflow question of this exact same error and no one has definitely provided an answer to this.
My production app only sometimes gives this error per my reporting service, so I am thinking two things:
Internet connection blipped out which it often does
There's some React Native timeout or under the hood machinery that cancels the attempt if the server hasn't returned anything.
To clarify:
fetch().then((response) => {
// Server returned something, even 500
}).catch((e) => {
// Server returned nothing OR internet connection bad?
// RN doesn't care to share why, just "I couldn't fetch"
});
since the fetch function is a javascript function, let's see what MDN docs say :
A fetch() promise will reject with a TypeError when a network error is encountered or CORS is misconfigured on the server side, although this usually means permission issues or similar — a 404 does not constitute a network error, for example.