title: Google Cloud PubSub/Datastore Error 13 & 14: "GOAWAY received" and "TCP Read/Write Fail"
body: <p>Sorry for the long title. Having some issues randomly pop up (every handful of hours, but not on a regular schedule, could be anywhere from 3 hours to 8) when streaming data from Cloud PubSub into Cloud Datastore using Cloud Functions.</p>
  
  <p>Source is a Node.js 6 script that receives an HTTP Post with info, writes to PubSub topic, then publishes topic to Cloud Datastore.</p>
  
  <p>It is a modified version of this:
  <a href="https://github.com/CiscoSE/serverless-cmx" rel="nofollow noreferrer">https://github.com/CiscoSE/serverless-cmx</a></p>
  
  <p>Errors:</p>
  
  <p>This first one happens sometimes with TCP Write instead of Read, but it's the same error.</p>
  
  <pre><code>ERROR: { Error: 14 UNAVAILABLE: TCP Read failed
      at Object.exports.createStatusError (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/common.js:87:15)
      at Object.onReceiveStatus (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:1188:28)
      at InterceptingListener._callNext (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:564:42)
      at InterceptingListener.onReceiveStatus (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:614:8)
      at callback (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:841:24)
    code: 14,
    metadata: Metadata { _internal_repr: {} },
    details: 'TCP Read failed' }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>ERROR: { Error: 13 INTERNAL: GOAWAY received
      at Object.exports.createStatusError (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/common.js:87:15)
      at Object.onReceiveStatus (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:1188:28)
      at InterceptingListener._callNext (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:564:42)
      at InterceptingListener.onReceiveStatus (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:614:8)
      at callback (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:841:24)
    code: 13,
    metadata: Metadata { _internal_repr: {} },
    details: 'GOAWAY received' }
  </code></pre>