Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

catch errors from createTimeSeries #1066

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

greensopinion
Copy link

Avoid crashing NodeJS with an unhandledRejection
by catching errors from createTimeSeries.

createTimeSeries can fail with an unhandled promise rejection, which will by default cause the NodeJS process to exit.
By handling the error gracefully, the process can continue to run.

Added a corresponding test.

Error: 3 INVALID_ARGUMENT: One or more TimeSeries could not be written: One or more points were written more frequently than the maximum sampling period configured for the metric.: global{} timeSeries[0]: custom.googleapis.com/canary/weather/all{} at Object.callErrorFromStatus (/usr/src/app/node_modules/@grpc/grpc-js/build/src/call.js:31:19) at Object.onReceiveStatus (/usr/src/app/node_modules/@grpc/grpc-js/build/src/client.js:195:52) at Object.onReceiveStatus (/usr/src/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141) at Object.onReceiveStatus (/usr/src/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181) at /usr/src/app/node_modules/@grpc/grpc-js/build/src/call-stream.js:188:78 at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
at ServiceClientImpl.makeUnaryRequest (/usr/src/app/node_modules/@grpc/grpc-js/build/src/client.js:163:34)
at ServiceClientImpl.<anonymous> (/usr/src/app/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
at /usr/src/app/node_modules/@google-cloud/monitoring/build/src/v3/metric_service_client.js:218:29
at /usr/src/app/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
at OngoingCallPromise.call (/usr/src/app/node_modules/google-gax/build/src/call.js:67:27)
at NormalApiCaller.call (/usr/src/app/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)
at /usr/src/app/node_modules/google-gax/build/src/createApiCall.js:84:30
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 3,
details: 'One or more TimeSeries could not be written: One or more points were written more frequently than the maximum sampling period configured for the metric.: global{} timeSeries[0]: custom.googleapis.com/canary/weather/all{}',
metadata: Metadata {
internalRepr: Map(3) {
'grpc-server-stats-bin' => [Array],
'google.monitoring.v3.createtimeseriessummary-bin' => [Array],
'grpc-status-details-bin' => [Array]
},
options: {}
}
}

Avoid crashing NodeJS with an unhandledRejection
by catching errors from createTimeSeries.
@google-cla
Copy link

google-cla bot commented Feb 4, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant