title: Google cloud pub/sub function gives "The requested snapshot version is too old" when querying firestore
body: <p>I have a gcloud pub/sub-function that performs a simple query on a collection. It was working fine before Oct 08. Now I am seeing &quot;The requested snapshot version is too old&quot; error messages.</p>
  <p>I have created an HTTP function with the same code and run it manually, it works perfectly fine.</p>
  <p>Here is the function:</p>
  <pre><code>// 0 3 * * * - at 03:00 AM every day
  exports.GenerateRankings = functions.pubsub.schedule('0 3 * * *')
      .onRun((context) =&gt; {
  
          console.log(&quot;GenerateRankings Task started&quot;)
  
          const playersCollection = admin.firestore().collection('players')
  
          playersCollection.orderBy(&quot;Coin&quot;, &quot;desc&quot;).get()
              .then((qs) =&gt; {
                  console.log(&quot;Fetching Players by Coin&quot;)
                  // some staff
                  return true
              })
              .catch((error) =&gt; {
                  console.error(&quot;Error fetching players&quot;, error)
                  return false
              })
      })
  </code></pre>
  <p>And here is the error stack:</p>
  <pre><code>9 FAILED_PRECONDITION: The requested snapshot version is too old.
   at Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
   at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:327:49)
   at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:305:181)
   at /workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:124:78
   at processTicksAndRejections (internal/process/task_queues.js:79:11)
   Caused by: Error
   at Query._get (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:1466:23)
   at Query.get (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:1455:21)
   at /workspace/index.js:22:47
   at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:130:23)
   at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:198:28
   at processTicksAndRejections (internal/process/task_queues.js:97:5) {
      code: 9,
      details: 'The requested snapshot version is too old.',
      metadata: Metadata { internalRepr: Map {}, options: {} }
   }
  </code></pre>
  <p>I know there is another unanswered question
  <a href="https://stackoverflow.com/questions/60175102/the-requested-snapshot-version-is-too-old-error-in-firestore">&quot;The requested snapshot version is too old.&quot; error in Firestore</a>
  similar to this. I am facing this problem with pub/sub-functions.</p>
  <p>Thanks for your help.</p>