fix: potential fix for firestore grpc connection reset

This commit is contained in:
Yanlong Wang 2025-03-08 21:37:55 +08:00
parent fd328cbcc2
commit 4830ff5fda
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37
2 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
FROM lwthiker/curl-impersonate:0.6-chrome-slim-bullseye
FROM node:20
FROM node:22
RUN apt-get update \
&& apt-get install -y wget gnupg \

View File

@ -519,7 +519,19 @@ export class CrawlerHost extends RPCHost {
async queryCache(urlToCrawl: URL, cacheTolerance: number) {
const digest = this.getUrlDigest(urlToCrawl);
const cache = (await Crawled.fromFirestoreQuery(Crawled.COLLECTION.where('urlPathDigest', '==', digest).orderBy('createdAt', 'desc').limit(1)))?.[0];
const cache = (
await
(Crawled.fromFirestoreQuery(
Crawled.COLLECTION.where('urlPathDigest', '==', digest).orderBy('createdAt', 'desc').limit(1)
).catch((err) => {
this.logger.warn(`Failed to query cache, unknown issue`, { err });
// https://github.com/grpc/grpc-node/issues/2647
// https://github.com/googleapis/nodejs-firestore/issues/1023
// https://github.com/googleapis/nodejs-firestore/issues/1023
return undefined;
}))
)?.[0];
if (!cache) {
return undefined;