具有云功能的Cloud Vision:重试方法中发生异常,该方法未分类为瞬态



我从使用Cloud Vision API的Cloud函数中得到以下错误:

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' }

代码如下:

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' });
});

不确定这是否与Firebase今天遇到的问题有关?

我通过使用google-gax版本1.15.2添加并添加以下分辨率来解决此问题:

"resolutions": {
"google-gax": "1.15.2"
},

最新更新