I've been getting the following error from a Cloud function that uses the Cloud Vision API:
Error: 1 CANCELLED: The operation was cancelled.
at Object.callErrorFromStatus (/srv/functions/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
at Http2CallStream.call.on (/srv/functions/node_modules/@grpc/grpc-js/build/src/client.js:96:33)
at Http2CallStream.emit (events.js:203:15)
at Http2CallStream.EventEmitter.emit (domain.js:466:23)
at process.nextTick (/srv/functions/node_modules/@grpc/grpc-js/build/src/call-stream.js:100:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
code: 1,
details: 'The operation was cancelled.',
metadata:
Metadata {
internalRepr:
Map {
'google.rpc.debuginfo-bin' => [Array],
'grpc-status-details-bin' => [Array] },
options: {} },
note:
'Exception occurred in retry method that was not classified as transient' }
The code is as follows:
const vision = require('@google-cloud/vision');
const client = new vision.ImageAnnotatorClient();
const [result] = await client.textDetection(`gs://${process.env.GCLOUD_PROJECT}.appspot.com/${fileName}`)
.catch((err: any) => {
return db.doc(event.ref.path).update({ status: 'error' });
});
Not sure if this has to do with the problems Firebase had today?
I resolved this by adding using google-gax
version 1.15.2 and adding the following resolution:
"resolutions": {
"google-gax": "1.15.2"
},