Error thrown while updating the device push token with the server

Please provide the following:

  1. SDK Version: expo@44.0.4
  2. Platforms(Android/iOS):
  3. Notifications

Hi,

Since updating to SDK 44 we have been intermittently receiving the following error in our app related to expo-notifications.

Error: Error encountered while fetching Expo token: TypeError: Network request failed.

I have been unable to replicate the issue via EXPO go or on the standalone app, I am only aware of the issue thanks to the app’s sentry integration. The issue occurs on both iOS and Android devices across multiple OS versions. The majority of users devices do not seem to have the issue and the PUSH notifications work as expected on devices I have access to.

If anyone has any ideas what might be causing the issue it would be great help.

Token Request:

/**
* Get EXPO notification token
*
* @returns {Object}    A JSON object of expo token
*/
export async function getTokenAsync () {
  // Request token
  let experienceId
  if (!Constants.manifest) {
    // Absence of the manifest means we're in bare workflow
    experienceId = '@username/example'
  }
  const expoPushToken = await Notifications.getExpoPushTokenAsync({
    experienceId
  })

  return expoPushToken
}

Log
xhr

POST https://exp.host/--/api/v2/push/getExpoPushToken [0]

Info

12:11:17

xhr

POST https://exp.host/--/api/v2/push/updateDeviceToken [0]

Info

12:11:18

console

[expo-notifications] Error thrown while updating the device push token with the server: TypeError: Network request failed

{arguments: [[expo-notifications] Error thrown while updating the device push token with the server:, {}], logger: console}

Warning

12:11:18

xhr

POST https://exp.host/--/api/v2/push/updateDeviceToken [0]

Info

12:11:19

console

[expo-notifications] Error thrown while updating the device push token with the server: TypeError: Network request failed

{arguments: [[expo-notifications] Error thrown while updating the device push token with the server:, {}], logger: console}

Warning

12:11:19

exception

Error: Error encountered while fetching Expo token: TypeError: Network request failed.

Error

12:11:19

Hey @wasp24, could you let me know when you upgraded to SDK44 and when you first started receiving reports for this error?

Hi @adamjnav, We started seeing the error, after the standalone app with the SDK 44 (44.0.4) update was released to the Play store on the 27th Jan. The issue then only started impacting the iOS app after the App store release on the 29th Jan. The app version number against the error in sentry also confirmed it was only occurring on the updated app on both iOS and Android.

If it helps, for one of the 1.9k errors we have logged so far was at Jan 31, 2022 4:18:59 PM GMT. Before and after the below error was logged other network request completed successful and the device reported it was connected to WiFi with an internet connection.

xhr
POST https://exp.host/--/api/v2/push/getExpoPushToken [0]
Info
16:18:57
xhr
POST https://exp.host/--/api/v2/push/updateDeviceToken [0]
Info
16:18:57
console
[expo-notifications] Error thrown while updating the device push token with the server: TypeError: Network request failed
{
arguments: [
[expo-notifications] Error thrown while updating the device push token with the server:, 
{}
], 
logger: console
}
Warning
16:18:57
xhr
POST https://exp.host/--/api/v2/push/updateDeviceToken [0]
Info
16:18:58
console
[expo-notifications] Error thrown while updating the device push token with the server: TypeError: Network request failed
{
arguments: [
[expo-notifications] Error thrown while updating the device push token with the server:, 
{}
], 
logger: console
}
Warning
16:18:58
exception
Error: Error encountered while fetching Expo token: TypeError: Network request failed.
Error
16:18:59

Hi @adamjnav, Wondering if you had any luck looking into the issue. I have been able to isolate the issue when it occurs by wrapping the getExpoPushTokenAsync call in a try catch. I have also been able to confirm that if a device experiences this issue, it is often able to retrieve a token successfully the next time the getExpoPushTokenAsync method is called.

Hi @adamjnav, Update on the issue, we have now started seeing the following in sentry in addition to the call to token service returning a status code 0.

xhr
POST https://exp.host/--/api/v2/push/getExpoPushToken [502]
Info
09:30:09
console
N016: Expo Notifications Token error, error requesting Expo token
{
arguments: [
N016: Expo Notifications Token error, error requesting Expo token
], 
logger: console
}
Info
09:30:09
console
Error: Error encountered while fetching Expo token, expected an OK response, received: 502 (body: "<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
").

Hi @adamjnav, We are still seeing this issue and noticed we are getting 504 Gateway Time-outs whilst sending notifications, It can take the service up to 7 seconds to fail one request. Do you know what might be coursing the issues?

Response:

<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.