I have followed the Node.js instructions here
I have an express server deployed to Cloud Run. If I use the express middleware and send an error to next(), as in the documentation, it shows up in Error Reporting.
However, if I use the report method in various forms like below, nothing is reported.
// Report an Error object
errors.report(new Error('My error message'), () => {
console.log('Done reporting Error object!');
});
// Report an error by provided just a string
errors.report('My error message', () => {
console.log('Done reporting error string!');
});
// Use the error message builder to customize all fields ...
const errorEvent = errors.event();
// Add error information
errorEvent.setMessage('My error message');
errorEvent.setUser('root@nexus');
// Report the error event
errors.report(errorEvent, () => {
console.log('Done reporting error event!');
});
I have tried adding the IAM role "Error Reporter Writer" to my (AppEngine default) service account that I used to deploy to Cloud Run, but it still doesn't work.
The TS compiler also doesn't accept the callback function as is used in the examples, so either the examples are outdated or the TS type definitions are wrong.
Any ideas?
I attempted to reproduce your error and found out some few things such as this warning:
For Error Reporting Client Library to work with Cloud Run, make sure that:
NODE_ENVwhich contains valueproduction. Or addreportModewhen instantiating the client:Here's a sample where I was able to submit to Error Reporting using
report()method: