title: Increase timeout time in React - neo4j app
body: <p>I am trying to increase the timeout time of my <code>React</code> app. I am using <code>axios</code>, so initially I tried:</p>
  
  <pre><code>axios.post('/gene_info', postData, {timeout: timeoutVal});
  </code></pre>
  
  <p>It did not work, and there is the respective thread that deals with it:</p>
  
  <p><a href="https://github.com/axios/axios/issues/647" rel="nofollow noreferrer">https://github.com/axios/axios/issues/647</a></p>
  
  <p>So, I tried the following code:</p>
  
  <pre><code> let CancelToken = axios.CancelToken;
        const source = CancelToken.source();
        try {
            let response = null;
            setTimeout(() =&gt; {
                if (response === null) {
                    source.cancel();
                }
            }, 60 * 1500 * 1000);
  
            response = await axios.post('/gene_info', postData, {cancelToken: source.token});
            console.log(response);
        } catch (error) {
            console.log(error);
        }
  </code></pre>
  
  <p>And it is not working either. The request times out and I see the empty response error, even though on the <code>Node.js</code> backend I see that the result is returned correctly. On the backend I am making a very long running request to <code>Neo4j</code> database. I got a suspicion that maybe it timeouts, so I added to <code>neo4j.config</code> file the following lines:</p>
  
  <pre><code>unsupported.dbms.executiontime_limit.enabled=true
  unsupported.dbms.executiontime_limit.time=99999999999999s
  </code></pre>
  
  <p>That I found here: </p>
  
  <p><a href="https://stackoverflow.com/questions/37400476/how-to-configure-a-query-timeout-in-neo4j-3-0-1">How to configure a query timeout in Neo4j 3.0.1</a></p>
  
  <p>and restarted <code>neo4j</code> but it did not help either. Here is what I see in the terminal:</p>
  
  <p><a href="https://i.stack.imgur.com/c7uYz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c7uYz.png" alt="enter image description here"></a></p>
  
  <p>I am not sure what this <code>POST /gene_info - - ms - -</code> means, whether the problem is still on the front end, or the back end, but I have a suspicion that <code>neo4j</code> now times out, but it is still calculating the result which I see using <code>console.log()</code> statements. Any suggestions would be greatly appreciated.</p>
  
  <blockquote>
    <p>Update</p>
  </blockquote>
  
  <p>I tried using <code>Reacts</code> <code>fetch</code>, but still not working. Here is the code:</p>
  
  <pre><code>fetchWithTimeout = (url, postData, timeout) =&gt; {
  let didTimeOut = false;
  
  new Promise(function(resolve, reject) {
      const timeout = setTimeout(function() {
          didTimeOut = true;
          reject(new Error('Request timed out'));
      }, timeout);
  
      fetch(url, {
          method: 'POST',
          headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          },
          timeout: timeout,
          body: JSON.stringify(postData)
      })
      .then(function(response) {
          // Clear the timeout as cleanup
          clearTimeout(timeout);
          if(!didTimeOut) {
              console.log('fetch good! ', response);
              resolve(response);
          }
      })
      .catch(function(err) {
          console.log('fetch failed! ', err);
  
          // Rejection already happened with setTimeout
          if(didTimeOut) return;
          // Reject with error
          reject(err);
      });
  })
  .then(function() {
      // Request success and no timeout
      console.log('good promise, no timeout! ');
  })
  .catch(function(err) {
      // Error: response error, request timeout or runtime error
      console.log('promise error! ', err);
  });
  }
  </code></pre>
  
  <p>Then I am calling this function like that:</p>
  
  <pre><code>let postData = {"jsonData": geneNameArr,
                      "datasetName": this.props.datasetName};
  this.fetchWithTimeout('/gene_info', postData, timeout).then((response) =&gt; {
          console.log("fetchWithTimeout is done!");
          console.log(response);
        });
  </code></pre>
  
  <blockquote>
    <p>Update</p>
  </blockquote>
  
  <p>I tried using <code>axios.create()</code> function with no success:</p>
  
  <pre><code>  const axiosInstance = axios.create({
          baseURL: '/gene_info',
          timeout: timeout
      });
  
      axiosInstance.post('', postData).then((response) =&gt; {
        console.log("axios request is done with create() method");
        console.log(response);
      });
  </code></pre>
  
  <p>If nothing seems to work on the front end, I would think it is the timeout that comes from the <code>neo4j</code> driver, even though somehow the results are returned. Here is the code I am using for the driver:</p>
  
  <pre><code>router.post('/gene_info', function(req, res) {
  ...
  ...
  var driver = dbUtils.driver;
  const session = driver.session();
  session.run(
    full_query,
    {}
   ).then(result =&gt; {
    const exprData = chartService.prepareGeneInfoData(result, '');
    res.json({
      exprData
    });
  
    session.close();
  });
  })
  </code></pre>
  
  <p>Or maybe it can also be <code>express.Router();</code> that I am using for treating <code>get</code> and <code>post</code> requests on the backend with <code>Node.js</code></p>