Skip to content
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

[Bug]: Winston logger running into "Maximum call stack size exceeded" error #2233

Open
Shahtaj-Khalid opened this issue Nov 4, 2022 · 1 comment

Comments

@Shahtaj-Khalid
Copy link

Shahtaj-Khalid commented Nov 4, 2022

🔎 Search Terms

Maximum call stack size exceeded

The problem

I'm getting following error from winston logger when large no. of logs are emitted during the short interval of time :

RangeError: Maximum call stack size exceeded
    at Date.[Symbol.toPrimitive] (<anonymous>)
    at Date.toJSON (<anonymous>)
    at JSON.stringify (<anonymous>)
    at Format.jsonFormatter [as transform] (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/src/Logging.ts:69:30)
    at DerivedLogger._transform (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:313:29)
    at DerivedLogger.Transform._read (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/readable-stream/lib/_stream_transform.js:177:10)
    at DerivedLogger.Transform._write (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/readable-stream/lib/_stream_transform.js:164:83)
    at doWrite (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at DerivedLogger.Writable.write (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/readable-stream/lib/_stream_writable.js:307:11)

and after some time, this error changes into

RangeError: Maximum call stack size exceeded
    at Function.assign (<anonymous>)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:50:36)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)
    at DerivedLogger.value (/Users/shahtajkhalid/Documents/go/src/bitbucket.org/securitiai/n8n/packages/nodes-base/node_modules/winston/lib/winston/logger.js:67:18)

What version of Winston presents the issue?

v3.6.0

What version of Node are you using?

v13 latest

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

Code Specifications :

We are creating a global logger, using transport (Console) - like this :

const GLOBAL_LOGGER = winston.createLogger({
		transports: [
			new winston.transports.Console()
		],
		format: winston.format(jsonFormatter)(),
		level: "debug"
	}
);

we are creating child loggers for every class in our code

GLOBAL_LOGGER.child({"logger": name});

Some Info about the system:

We are listening to messages from Kafka, and every time a message arrives, we do so pre-processing which includes some db calls along with some I/O operations and then move forward with the processing.

How to reproduce ?

Every time we emit 6K messages or more at a time, we get this error after around 10 minutes of processing. This issue is reproducible pretty much every time when bulk of messages are received back to back.

Once we get this Maximum call stack size exceeded error, no more logs gets emitted from the main process from Winston Logger after it (Nodejs's console logs continues to work).
Also note: we are spinning sub-processes later in the code after some pre-processing against per message and logs from the sub-processes are being emitted fine from the winston logger. but the logs from the main NodeJs process are effected with this error.

We really need a solution for this as we have been facing this issue from some time now, and currently using the latest version of Winston logger as well. Kindly let us know if there is anything we can do to fix this or if any further information is required to get this fixed within the library.

Thank you.

Additional information

It is high priority issue for us as it is effecting our prod environment.

@wbt
Copy link
Contributor

wbt commented Nov 4, 2022

The reproduction example isn't sufficient to reproduce the problem. It's not even logging a single message.

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

No branches or pull requests

2 participants