-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
api: loggingIssues related to the googleapis/nodejs-logging-winston API.Issues related to the googleapis/nodejs-logging-winston API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.
Description
Please make sure you have searched for information in the following guides.
- Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
A screenshot that you have tested with "Try this API".
Not a problem with the API, a problem with the library
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
https://gist.github.com/RLRabinowitz/d37492e3627e73c14e1cbe16ba1162a9
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
Have the following code:
// NOTE - These should be valid credentials, but should miss the `client_email` field:
const credentials = {...}
const transport = new LoggingWinston({
logName: "my-log-name",
projectId: "my-project-id",
credentials,
defaultCallback: (error, apiResponse) => {
if (error) {
logger.error('GCP Transport got error', { error, apiResponse: JSON.stringify(apiResponse) });
}
}
})
const loggerOptions = {
levels: winston.config.syslog.levels,
level: 'debug',
transports: [transport],
exitOnError: false
}
const logger = winston.createLogger(loggerOptions);
// Try to log
logger.info('test')
// Wait 3 seconds
await new Promise(resolve => setTimeout(resolve, 3000));
A clear and concise description of what the bug is, and what you expected to happen.
You get the following crash, as an Unhandled Exception:
Error: The incoming JSON object does not contain a client_email field
at JWT.fromJSON (/Users/arelrabinowitz/Projects/myproject/node_modules/.pnpm/[email protected][email protected]/node_modules/google-auth-library/build/src/auth/jwtclient.js:203:19)
at GoogleAuth.fromJSON (/Users/arelrabinowitz/Projects/myproject/node_modules/.pnpm/[email protected][email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:435:20)
at GoogleAuth._cacheClientFromJSON (/Users/arelrabinowitz/Projects/myproject/node_modules/.pnpm/[email protected][email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:447:29)
at GoogleAuth.getClient (/Users/arelrabinowitz/Projects/myproject/node_modules/.pnpm/[email protected][email protected]/node_modules/google-auth-library/build/src/auth/googleauth.js:665:22)
at GrpcClient._getCredentials (/Users/arelrabinowitz/Projects/myproject/node_modules/.pnpm/[email protected][email protected]/node_modules/google-gax/build/src/grpc.js:145:40)
at GrpcClient.createStub (/Users/arelrabinowitz/Projects/myproject/node_modules/.pnpm/[email protected][email protected]/node_modules/google-gax/build/src/grpc.js:308:34)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
Adding a try/catch over the logger.info
would not help, and the defaultCallback
didn't help here either
A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
Logging with winston should not crash
Metadata
Metadata
Assignees
Labels
api: loggingIssues related to the googleapis/nodejs-logging-winston API.Issues related to the googleapis/nodejs-logging-winston API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.