Zipped Hosted Files Unzip after sync to GitHub


I use the hosting feature of Realm to store my single page (Angular) application which is hooked up and synchronised to my GitHub account. As part of my deployment process, I zip up one of the files and change the meta data in the file hosting/metadata.json e.g.


This all works fine. However, if I make a change in the UI and deploy to GitHub whilst Automatic Deployment is enabled the hosted file (in this case main.66c216826303f93d.js) unzips itself and therefore breaks the website as the browser tried to unzip the file again.

It appears related to this issue: Realm app auto deployment - not deploying Rules, Schema (but is deploying Functions, Triggers, etc.) - #3 by Christopher_Roth which was fixed a while back but possibly not for the zipped file use case.

Anyone else having similar problems?

@Mansoor_Omar just wondered if this is something you could check out for me? thanks

Hi Simon,

Could you elaborate a bit more on the workflow/steps.
If i understand correctly is this what you’re doing?:

  1. Upload hosting file in Realm cloud UI and deploy to github
  2. Zip the hosting file in github and commit back to Realm cloud
  3. Make any change in Realm cloud UI and deploy to github
  4. The file is in an unzipped state and breaks the website


1 Like

Hi Manny,

thanks for taking a look. To be more precise with my situation, it works like this…

  1. I have the Mongo Realm Automatic Deployment configured and connected to GitHub
  2. I update my Angular app in VS code and execute my build script locally
  3. the script zips up the main file “main.66c216826303f93d.js” (from 1.69MB to 452KB) and copies it to my MongoDB hosting folder which is synced with Realm
  4. the script also modifes hosting/metadata.json as described above
  5. Via VS Code I sync with GitHub
  6. The site all works fine and the browser knows to unzip the file due to the content encoding
  7. I make a change in the Realm UI (say a Realm function), and click “Save Draft” and “Deploy and Push to GitHub” (note that this can take over a minute for my site)
  8. At this point my site is broken - the browser tries to unzip the main.*.js file but can’t
  9. Upon inspecting the contents of the hosting folder via the Realm UI, I see the size of main.*.js is back to 1.69MB.
  10. Via the Realm UI, I remove the gzip Content-Encoding (see image below) and save - this fixes the site (however the file is no longer compressed as before)
  11. To fix properly, I sync VS code with GitHub, and di steps 2 to 5 above again.

Hopefully that explains a bit more clearly what is happening. I suspect that the code that syncs with GitHub zips and unzips the code but it should only unzip down to one level.

If you could raise this as a bug that would be much appreciated. Many thanks.


Hi Simon,

Thanks for that, after testing a few things I’ve raised this internally with all my discoveries.

It seems the issue is with the /hosting/metadata.json which is coming up blank on the cloud app but has a value in the github repo.

When you add the content-encoding attribute in the github repo and commit, it updates the cloud app state with a value for the metadata.json file but the /files folder on the cloud goes missing. This gets corrected when you do step 10 but you end up with a blank metadata.json file again on the cloud state. In fact if instead of removing the content encoding attribute in step 10, you were to make a different change in the UI like updating a function it would result in error as per my testing because there is a difference in the hosting directory between the cloud app and github repo.


1 Like

Thank you for investigating and raising it. Much appreciated.

1 Like