3

I'm trying to use aura storage in an app included from a VF page, but I have the following error. Same code works well for a standalone .app

Uncaught TypeError: $A.$clientService$.$initHost$ is not a function throws at https://xxxxxxx-developer-edition.eu11.force.com/distributor/auraFW/javascript/-Nl7t7IjS5oiqOIuVwZRSw/aura_proddebug.js:17270:24

Sample app code :

<aura:application access="GLOBAL" 
                  extends="ltng:outApp" 
                  description="Only used for visualforce page javascript inclusion of main big component">
                  template="c:TemplateAppForStorage"
    <aura:dependency resource="c:MyMainBigComponent"/>
</aura:application>

TemplateAppForStorage:

<aura:component isTemplate="true" extends="aura:template" description="App template to initialize storage">
    <aura:set attribute="auraPreInitBlock">
        <!-- Note that the maxSize attribute in auraStorage:init is in KB -->
        <auraStorage:init name="actions" 
                          persistent="false" 
                          secure="true"
                          maxSize="2048" />
    </aura:set>
</aura:component>

Sample of including vf page

<apex:page sidebar="false" showHeader="false" standardStylesheets="false"
       cache="false" applyBodyTag="false" applyHtmlTag="false"> 

    <apex:includeLightning />
    <div id="lightningvfDIV" style="min-height: 100% !important;display:block;"/>

    <script>
            $Lightning.use("c:MyAppForVfPage", function() {
                $Lightning.createComponent("c:MyMainBigComponent", 
                                           {},
                                           "lightningvfDIV",
                                           function(cmp) {
                                              console.log('Page includer initialized'); 
                                           });
            });  

    </script>        
3

Issue is specific to ltng:outApp's template not providing the environment that auraStorage:init is expecting.

I have opened bug W-3451404 to track this if you wan to reference this in any communications with Salesforce support.

1
  • I see too many bugs to bother SF support with them each time, I fully trust u to take them in account, many thanks for your reactivity Doug :) – Nicolas Vuillamy Nov 4 '16 at 11:21
1

If it's any help Nicolas if you change the init to be

<auraStorage:init name="actions" 
                          persistent="true" 
                          secure="false"
                          maxSize="2048" />

Then the error is removed. I.e. I changed the persistent and secure values. The persistent setting doesn't seem to work for me; ie if I refresh the page then it seems to skip the cache so that currently will not be a problem. However the cached data will be insecure which might be a bigger issue for you.

1
  • 1
    It doesn't trigger the inital crash but, it triggered ... unavailability of $Resource references (err 503 when getting bootstrap.css !) :/ And in the console I still see : "Uncaught error in $A.run() [$A.$clientService$.$initHost$ is not a function]" So i'll wait for Doug's fix :) – Nicolas Vuillamy Nov 7 '16 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.