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

Couldn't catch error of export function #995

Open
JasonRock opened this issue Jul 10, 2022 · 0 comments
Open

Couldn't catch error of export function #995

JasonRock opened this issue Jul 10, 2022 · 0 comments
Labels

Comments

@JasonRock
Copy link

JasonRock commented Jul 10, 2022

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

"@opencensus/exporter-stackdriver": "0.1.0"

What version of Node are you using?

v17.9.0

What did you do?

I create a simple time series view, and send points to GCP via StackdriverStatsExporter

const { StackdriverStatsExporter } = require('@opencensus/exporter-stackdriver');

const exporter = new StackdriverStatsExporter ({
    projectId: "MY_PROJECT_ID",
    period: 60* 1000,
    onMetricUploadError: function (err) {
        logger.error("MetricUploadError", err.message)
    },
});

What did you expect to see?

When error occur, my custom error should be print in logging system, such as:

MetricUploadError GaxiosError: 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.

What did you see instead?

My node process exits directly, instead of print error log. It can be verified by the following procedure

process.on('uncaughtException', function(err){
     console.log("process.on uncaughtException")
     console.log(err.stack)
})

The root cause

The start function called export function with try/catch statement, but export function is asynchronous and have no return value, so can't catch inner error in start function, and cause process exits.

The solution

async export() {
    // ...
    return this.createTimeSeries(metricsList);
}
@JasonRock JasonRock added the bug label Jul 10, 2022
@JasonRock JasonRock reopened this Jul 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant