react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

404 error when trying to download recent updates

Open Gamote opened this issue 1 year ago • 19 comments

Steps to Reproduce

  1. Publish an update
  2. Trigger a sync in the next 30 seconds
  3. Observe the 404 error

Expected Behavior

It is expected that we are not going to encounter a 404 error when the sync method gets the update.

Actual Behavior

What actually happens?

I think the issues is that the download url is available but not the content. So without having too much info about what is happening in the background I can only assume that it takes some that for the update to be available although it was 'advertised' as available.

2023-05-25 16:06:04.065306+0200 Airbnb[99456:9149076] [javascript] [CodePush] Downloading package.
2023-05-25 16:06:04.560066+0200 Airbnb[99456:9149076] [javascript] [CodePush] An unknown error occurred.
2023-05-25 16:06:04.560368+0200 Airbnb[99456:9149076] [javascript] [CodePush] Received 404 response from https://codepush-secondary.blob.core.windows.net/storagev2/...

The lowest we could go without an error was to try an sync 1 minute and 23 seconds after the update was pushed. This way we didn't get the 404 error. But I don't think that is not consistent.

Environment

  • react-native-code-push version: 8.0.1
  • react-native version: 0.64.4
  • iOS/Android/Windows version: 16.4
  • Does this reproduce on a debug build or release build? staging and release
  • Does this reproduce on a simulator, or only on a physical device? both simulator and physical device

Similar #2014

Gamote avatar May 30 '23 09:05 Gamote

Update: The lowest we could go is 31 seconds. If we try to sync faster than 31 seconds we are going to get the 404 error mentioned above.

Gamote avatar May 31 '23 16:05 Gamote

It's happening to us too and it's making it quite tricky to fix critical bugs

alwyntan avatar Jun 15 '23 03:06 alwyntan

Also seeing this!

jameskennethrobinson avatar Jun 18 '23 20:06 jameskennethrobinson

It's happening to us too and it's making it quite tricky to fix critical bugs

Same for us. At the moment we are forced in using "expo-updates" because we are afraid that a lot of our active users will interact with the app in those first 31 seconds after pushing the update.

Gamote avatar Jun 18 '23 20:06 Gamote

it's happening to our apps too. for some reason the user which get this issue will never get the update, until we have pushed the new update. to deal with it, after push the update, we disable the update on appcenter dashboard (user don't get the update), wait 5 minutes, enable it again. when user sync it, they don't get 404 error.

Screenshot 2023-06-28 at 11 14 17

ajitaro avatar Jun 28 '23 04:06 ajitaro

same issue.

It might be ok, except after this happens, the user can't download the version again. The system thinks the client has it already, and never tries to re-download it.

Is there at least a way to mark it as failed so it retries the download on next try?


In case anyone is wondering, the issue isn't triggered by calling localPackage.install, as I make sure that's not called if the remotePackage isn't downloaded:

const attemptUpdate = async () => {
  try {
    await codePush.notifyAppReady()

    const remotePackage = await codePush.checkForUpdate()

    if (!remotePackage || !removePackage.mandatory) return

    const localPackage = await remotePackage.download(onProgress)

    if (!window.updateDownloadPercent) {
       throw new Error('codePush package not ready yet (404)')
    }

    await localPackage.install(codePush.InstallMode.IMMEDIATE, 0)
  }
  catch (error) {
    captureException('codePush', error)
  }
}


const onProgress = ({ receivedBytes, totalBytes}) => {
  const percent = receivedBytes / totalBytes
  window.updateDownloadPercent = round2decimals(percent * 100)
}

The issue is called just by the act of downloading the remotePackage.

skinsapp avatar Aug 12 '23 03:08 skinsapp

Any updates on this?

Zakyyy avatar Sep 07 '23 12:09 Zakyyy

This error often occurs. Is there a solution?

dkahdwk avatar Sep 19 '23 07:09 dkahdwk

@dkahdwk @Zakyyy see my workaround here:

https://github.com/microsoft/react-native-code-push/issues/2585#issuecomment-1749375271

skam22 avatar Oct 05 '23 17:10 skam22

Well this is very much still an issue. An update that was detected but failed to download should be tried again later instead of being marked as rolled back. This issue should remain open.

Initial sync() call, very soon after publishing an update:

[CodePush] Checking for update.
[CodePush] Downloading package.
[CodePush] An unknown error occurred.
[CodePush] Received 404 response from https://codepush-secondary.blob.core.windows.net/storagev2/xxxxxxxxxxxxxxxxxxxxxxxxx

An update is detected, yet its download fails. It would be better if it didn't but hey, stuff happens.

Subsequent sync() call:

[CodePush] Checking for update.
[CodePush] An update is available, but it is being ignored due to having been previously rolled back.
[CodePush] App is up to date.

Why an update would be considered rolled back if it didn't even succeed at the download stage? Try again here would be the expected behaviour.

habovh avatar Jan 25 '24 16:01 habovh

@habovh i'm having the same error here, the exact same thing!

Victor-Roxcode avatar Jan 26 '24 14:01 Victor-Roxcode

This issue is not fixed yet. It occurs in my deployments seemingly randomly.

On Fri, Jan 26, 2024 at 07:39 Roxcode @.***> wrote:

@habovh https://github.com/habovh i'm having the same error here, the exact same thing!

— Reply to this email directly, view it on GitHub https://github.com/microsoft/react-native-code-push/issues/2527#issuecomment-1912172522, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB53IRLFFKDZYTMMEG4AFK3YQO53PAVCNFSM6AAAAAAYTXDYKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSGE3TENJSGI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jameskennethrobinson avatar Jan 26 '24 14:01 jameskennethrobinson

Still an issue, though now that AppCenter is being sunset it might be harder to get a fix right now.

Since this issue also highlights a back-end issue, I guess once we get the "community version" of CodePush server to be able to self-host, we'll be able to identify and fix the issue to prevent 404 in the first place.

habovh avatar Mar 27 '24 09:03 habovh

@habovh

Send your updates with the —disabled flag, and then manually enable it to avoid 404 errors.

skam22 avatar Mar 27 '24 16:03 skam22

Well this is very much still an issue. An update that was detected but failed to download should be tried again later instead of being marked as rolled back. This issue should remain open.

Initial sync() call, very soon after publishing an update:

[CodePush] Checking for update.
[CodePush] Downloading package.
[CodePush] An unknown error occurred.
[CodePush] Received 404 response from https://codepush-secondary.blob.core.windows.net/storagev2/xxxxxxxxxxxxxxxxxxxxxxxxx

An update is detected, yet its download fails. It would be better if it didn't but hey, stuff happens.

Subsequent sync() call:

[CodePush] Checking for update.
[CodePush] An update is available, but it is being ignored due to having been previously rolled back.
[CodePush] App is up to date.

Why an update would be considered rolled back if it didn't even succeed at the download stage? Try again here would be the expected behaviour.

Has this issue resolved ??

JasoliyaShruti avatar Mar 28 '24 11:03 JasoliyaShruti

@habovh

Send your updates with the —disabled flag, and then manually enable it to avoid 404 errors.

@skam22 yes I'm using a similar approach where I push to staging and promote, but that's still inconvenient and IMO the update should not be considered rolled back by the client if it failed to download in the first place.

habovh avatar Mar 28 '24 13:03 habovh

Issue is still relevant.

habovh avatar May 28 '24 14:05 habovh

This is still relevant.

habovh avatar Jul 28 '24 08:07 habovh