title: How to fix JavaScript heap out of memory
body: <p><a href="https://i.stack.imgur.com/E3lzY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E3lzY.png" alt="enter image description here" /></a><a href="https://i.stack.imgur.com/2y75C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2y75C.png" alt="enter image description here" /></a><strong>I am working with the google actions console. Here I have a webhook, see the code below. Now when I run this I get the following error:</strong></p>
  <p><em>FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory</em></p>
  <pre><code>const {
  conversation,
  Simple,
  Canvas,
  Card,
  Link,
  Suggestion,
  Image,
  } = require('@assistant/conversation');
  const functions = require('firebase-functions');    
  const app = conversation();
  
  const categories = {
      nhgooi: {
          antwoorden: [
          'Ze willen dat pedojager onmiddelijk stoppen.',
          'Ze willen dat pedojagers zo doorgaan.',
          'Ze willen dat pedojagers pedofielen nog harder aanpakken.',
          'Ze willen dat pedojagers pedofielen blijven zoeken maar ze minder hard aanpakken.',
          ],
          vraag: [
              &quot;Wat wilt de politie dat pedojagers doen?&quot;
          ],
          image: {
          url: &quot;https://storage.googleapis.com/gweb-uniblog-publish-prod/images/&quot; +
              &quot;Search_GSA.2e16d0ba.fill-300x300.png&quot;,
          alt: 'Google app logo',
          },
      },
      };
  
  
  function randomarray(i_array, antwoorden, category){ //make an array with items in random order
      while (i_array.length &gt; 0){
      i = Math.floor(Math.random() * i_array.length);
      var index = i - 1;
      antwoorden.push(categories[category].antwoorden[index]);
      delete i_array[index];
      }
      return antwoorden;
  }
  
  app.handle('NieuwsQuiz_Vragen', (conv) =&gt; {
      var antwoorden = [];
      var i_array = [0, 1, 2, 3];
      const category = conv.scene.slots.vraag_categorie.value; //gekozen categorie (regio)
      const vraag = categories[category].vraag[0];
      const antwoorden_shuffled = randomarray(i_array, antwoorden, category);
      const antwoorden_string = antwoorden_shuffled.toString();
      const image = categories[category].image[0];
  
      const prefix = `Jij hebt gekozen voor vragen uit ${category}, laten we snel beginnen!`;
      conv.add(prefix);
      const supportsRichResponse = conv.device.capabilities.includes(&quot;RICH_RESPONSE&quot;);
      if (supportsRichResponse) {
          conv.add(new Card({
          title: vraag,
          subtitle: antwoorden_string,
          image: new Image(image),
          button: new Link({
              name: 'Learn more',
              open: {
              url: 'https://www.google.com/about/'
              }
          })
          }));
      }
      // conv.add(new Simple({
      //     speech: `${prefix} ${vraag}`,
      //     text: vraag,
      // }));
  
      // for( let i=0 ; i &lt;= antwoorden.length ; i++ ) {
      //     conv.add(new Suggestion({title: antwoorden[i]})); 
      // }
      //conv.add(new Suggestion({title: 'Quit'}));
  });
  
  exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);
  </code></pre>
  <p><strong>Does anyone know how to fix this? I have looked into other questions around this problem on Stack but all those solutions were to use in the terminal and not in a webhook.</strong></p>