-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Winston Logging Transports crashing #381
Comments
Greetings! Can you share the code you're using to get this callstack? |
const { loggers, format } = require('winston');
const { LoggingWinston } = require('@google-cloud/logging-winston');
const {
combine, label, printf, splat,
} = format;
const logFormat = printf(info => `[${info.label}] ${info.level.toUpperCase()}: ${info.message}`);
const loggingWinston = new LoggingWinston({
serviceContext: {
service: 'api',
version: pjson.version,
},
logName: `logfile-v${pjson.version}.log`,
});
loggers.add('api', {
level: 'debug',
format: combine(label({ label: 'api'}), splat(), logFormat),
transports: [loggingWinston],
exitOnError: false,
silent: false,
}); This is how I initialize the logger, the error just intermittently goes out, cannot locate which actual code. When the error comes out, the LoggingWinston transport is not useful anymore, Winston logger still runs but cannot properly log into Stackdriver |
@alexander-fenster uh... do you recognize anything in this call stack? |
Somewhere in |
This is where we create nodejs-logging/src/v2/logging_service_v2_client.js Lines 142 to 151 in 05edc86
Here The call starts here: and the sequence of nested calls eventually comes to (and we fail trying to get Now the fun part is that the Logging library does great job making sure that Lines 783 to 807 in 6cf18aa
I can see the only way of having it undefined: it will happen if Long story short... googleapis/gax-nodejs#424 to make GAX not fail in this case, and in scope of this issue, we must make sure that |
It kind of seems like we shouldn't let that be |
@stephenplusplus I'm not sure what is our policy re: throwing exceptions from logging calls. I think users don't expect that regular log writes could throw 😱 Would it be OK if we make sure the |
Hello, Have you identified any circumstances that lead to this error? Would switching to another version help with this issue? |
Hello @seriousManual,
Yes and no. I made a fix googleapis/gax-nodejs#424 in exactly the place where it fails so it should not fail anymore (we'll release the new version of that package today). When all the dependency chain upgrades, the error condition should stop happening. As for what causes the error - i.e. what causes the undefined value to be passed to logging - I don't have an answer I'm confident in. One idea is that it might be doing that if it gets an object with circular references, but it makes me think there should be another explanation, given that all these bug reports started coming from several people at the same time. @stephenplusplus can I ask you to take a deeper look at what's going on (why this undefined value appears there)? |
Thank you for the efforts you're putting into this.
I'm glad it is not only us. How long do you think it will take until the fix patch has been introduced at the upstream deps? (gax -> nodejs-logging -> winston-logging) |
Hi, I would like to share my workaround as of this time, while waiting for the fix. |
To all who spent time on this issue, I would like to thank you for your dedication to solve this. I have been tracing all logging combination that we do in our code (NodeJS in App-Engine) to find what is the exact scenario this happen. But if this can be solved on your end, Thank you very much! |
Greetings folks, I have released google-gax v0.25.2 which should not crash in case if an undefined value is passed. From what I understand, it means you may get an incomplete / malformed log message but at least nothing will crash. Since logging uses |
Hi, I suppose that this is directly related to the fix? |
@seriousManual Yes, it's exactly that warning message that should be printed in this case. Note that it will be only printed once per each running process (otherwise your |
Hi Guys, I also did used the fix and deployed to our staging instance. Its been there for 3 days now and I never got the error again. Hopefully this is going to be stable now. Thanks a lot. |
Same here, Thank you! |
I observe the same issue with winston 3.2.1 and google-gax 1.0.0. I get the same error "Attempt to write logs with no transports" after a while. I can see there was a huge refactoring done recently in google-gax, so maybe there was a regression during the process ? |
@la-urre Did you ever get to the bottom of your issue? I am seeing the same thing currently. |
If you're running into issues, please open a new bug with details 🤗 |
Environment details
@google-cloud/logging
version: 4.2.0Steps to reproduce
The text was updated successfully, but these errors were encountered: