Issue Overview
I have a Vercel-deployed Next.js (v14.2.16) application that frequently encounters 500
errors on two public pages. These pages fetch data from Firebase Firestore using thier admin sdk.
Key Observations
- The errors seem to resolve automatically upon refreshing the page.
- These errors are not being caught by any error handlers in the application, including:
- Middleware
try/catch
blocks- Firebase Admin SDK initialization
- Database access functions
- This suggests that the app may be failing before rendering starts.
Behavior Details
-
Reproducibility: The errors are inconsistent and unpredictable. They sometimes occur when directly accessing a URL or refreshing the page after a delay.
-
Vercel Logs: The logs show an error with the message:
Unhandled Rejection: Error: 4 DEADLINE_EXCEEDED: Deadline exceeded after 76.714s,LB pick: 0.001s,remote_addr=142.250.31.95:443 at callErrorFromStatus (/var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call.js:31:19) at Object.onReceiveStatus (/var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:193:76) at Object.onReceiveStatus (/var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141) at Object.onReceiveStatus (/var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181) at /var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/resolving-call.js:129:78 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) for call at at ServiceClientImpl.makeUnaryRequest (/var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:161:32) at ServiceClientImpl.<anonymous> (/var/task/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19) at /var/task/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:237:29 at /var/task/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16 at repeat (/var/task/node_modules/google-gax/build/src/normalCalls/retries.js:82:25) at /var/task/node_modules/google-gax/build/src/normalCalls/retries.js:125:13 at OngoingCallPromise.call (/var/task/node_modules/google-gax/build/src/call.js:67:27) at NormalApiCaller.call (/var/task/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19) at /var/task/node_modules/google-gax/build/src/createApiCall.js:112:30 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Caused by: Error at _firestore._traceUtil.startActiveSpan (/var/task/node_modules/@google-cloud/firestore/build/src/write-batch.js:438:27) at DisabledTraceUtil.startActiveSpan (/var/task/node_modules/@google-cloud/firestore/build/src/telemetry/disabled-trace-util.js:16:16) at WriteBatch.commit (/var/task/node_modules/@google-cloud/firestore/build/src/write-batch.js:436:43) at /var/task/node_modules/@google-cloud/firestore/build/src/reference/document-reference.js:396:18 at DisabledTraceUtil.startActiveSpan (/var/task/node_modules/@google-cloud/firestore/build/src/telemetry/disabled-trace-util.js:16:16) at DocumentReference.update (/var/task/node_modules/@google-cloud/firestore/build/src/reference/document-reference.js:390:43) at d (/var/task/.next/server/chunks/175.js:6:413155) at o (/var/task/.next/server/chunks/175.js:1:35598) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:418 { code: 4, details: 'Deadline exceeded after 76.714s,LB pick: 0.001s,remote_addr=142.250.31.95:443', metadata: Metadata { internalRepr: Map(0) {}, options: {} }, note: 'Exception occurred in retry method that was not classified as transient'} Node.js process exited with exit status: 128. The logs above can help with debugging the issue.
-
Execution Timing:
Despite the error message indicating “Deadline exceeded after 76.714s,” the execution duration shown in the logs is just 32ms. This suggests the error might be caused by cumulative retries or network-layer issues.
Error Handling
All functions in the application include try/catch
blocks to handle potential errors, but none of them seem to log or execute in this case.
Vercel Log Snapshot
From the log, the execution duration is just 32ms, contradicting the stated deadline of 76.714s.
Environment Details
- Next.js:
14.2.16
- Firebase:
10.13.2
- Firebase Admin:
12.7.0
Request for Help
Any ideas on what might be causing this issue and potential fixes? I’m open to suggestions for improving error handling or mitigating these random failures.