title: Why the second CAA query does not timeout?
body: <p>I have a piece of node.js code which checks the <a href="https://en.wikipedia.org/wiki/DNS_Certification_Authority_Authorization" rel="nofollow noreferrer">CAA record</a> of a specific domain.</p>
  
  <pre><code>const dns = require('dns-socket')
  const defaultDNS = '10.11.1.5'  // My DNS server
  const socket = dns()
  
  function checkCaa (domainName) {
    console.log(`domainName: ${domainName}`)
    socket.query({
      questions: [{
        type: 'CAA',
        name: domainName
      }]
    }, 53, defaultDNS, (err, res) =&gt; {
      console.error(`Error: ${err}`)
      console.log(`Response: ${JSON.stringify(res)}`)
      socket.destroy()
    })
  }
  
  checkCaa('www.babushop.com.tw')
  </code></pre>
  
  <p><code>www.babushop.com.tw</code> is a domain that has no CAA record.</p>
  
  <p>When I execute the above code for the first time, the program outputs:</p>
  
  <pre><code>domainName: www.babushop.com.tw
  Error: Error: Query timed out
  Response: undefined
  </code></pre>
  
  <p>As you can see from the output, it says the query timed out.</p>
  
  <p>I'd like to know why it gives the following output when I run it for the second time:</p>
  
  <pre><code>domainName: www.babushop.com.tw
  Error: null
  Response: {"id":22260,"type":"response","flags":384,"flag_qr":true,"opcode":"QUERY","flag_auth":false,"flag_trunc":false,"flag_rd":true,"flag_ra":true,"flag_z":false,"flag_ad":false,"flag_cd":false,"rcode":"NOERROR","questions":[{"name":"www.babushop.com.tw","type":"CAA","class":"IN"}],"answers":[{"name":"www.babushop.com.tw","type":"CNAME","class":"IN","ttl":42,"flush":false,"data":"s2454.dname.91app.io"},{"name":"s2454.dname.91app.io","type":"CNAME","class":"IN","ttl":42,"flush":false,"data":"proxy.letssl.91app.io"},{"name":"proxy.letssl.91app.io","type":"CNAME","class":"IN","ttl":56,"flush":false,"data":"proxy-letssl-91app-io-196811564.ap-northeast-1.elb.amazonaws.com"}],"authorities":[],"additionals":[]}
  </code></pre>
  
  <p>Is something cached in my DNS server(10.11.1.5 in this case) so that it doesn't time out? </p>
  
  <p>If so, what is it?</p>
  
  <p>This phenomenon makes me difficult to determine whether the CAA query will time out or not.</p>