question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maximum call stack size exceeded

See original GitHub issue

in this code

server.type('LOAD_NEXT_CANDLE', {
	async access(ctx) { return true },
	async resend(ctx) {
		console.log('resent')
		return 'candles-channel'
	},
	async process() {
		let candle = await CandleModel.findOne()

		server.log.add({ type: 'candles/new', candle }, { channels: ['candles-channel'] })
	}
})

when ‘LOAD_NEXT_CANDLE’ is dispatched on the client and the process is called on the server, I get this error:

 FATAL  Maximum call stack size exceeded at 2021-06-22 02:51:36
        at String.replace (<anonymous>)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:230:23)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)
        at cleanFromKeys (file:///path/to/project/node_modules/@logux/server/create-reporter/index.js:232:21)

If I comment out the line that is making a call to the Database and send a fake candle, there’s no error

server.type('LOAD_NEXT_CANDLE', {
	async access(ctx) { return true },
	async resend(ctx) {
		console.log('resent')
		return 'candles-channel'

	},
	async process() {
		// let candle = await CandleModel.findOne()
		let candle = {
			"_id": "60d0fae173565825312222ca",
			"pair": "eurusd",
			"timeframe": "1h",
			"date": "2000.01.03",
			"time": "19:00",
			"o": 1.0205,
			"h": 1.024,
			"l": 1.015,
			"c": 1.025,
			"v": 355,
		}
		server.log.add({ type: 'candles/new', candle }, { channels: ['candles-channel'] })
	}
})

If I do make a query to the database but still send the fake candle to the client, there’s no error:

server.type('LOAD_NEXT_CANDLE', {
	async access(ctx) { return true },
	async resend(ctx) {
		console.log('resent')
		return 'candles-channel'

	},
	async process() {
		let dbCandle = await CandleModel.findOne()
		let candle = {
			"_id": "60d0fae173565825312222ca",
			"pair": "eurusd",
			"timeframe": "1h",
			"date": "2000.01.03",
			"time": "19:00",
			"o": 1.0205,
			"h": 1.024,
			"l": 1.015,
			"c": 1.025,
			"v": 355,
		}
		server.log.add({ type: 'candles/new', candle }, { channels: ['candles-channel'] })
	}
})

how do I fix this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Jun 21, 2021

Hm. I will try to look later today.

0reactions
aicommented, Jun 24, 2021

I added a better warning for cases like this

84c0aff

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Maximum call stack size exceeded error
It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you...
Read more >
JavaScript Error: Maximum Call Stack Size Exceeded
If you see the “Maximum Call Stack Size Exceeded” error, there's likely a problem with a recursive function within your JavaScript code.
Read more >
RangeError: Maximum call stack size exceeded
The most common source for this error is infinite recursion. You must have a recursive function in your code whose base case is...
Read more >
Uncaught RangeError: Maximum call stack size exceeded
Maximum call stack size exceeded error ... This error is almost always means you have a problem with recursion in JavaScript code, as...
Read more >
How to fix: "RangeError: Maximum call stack size exceeded"
A "RangeError: Maximum call stack size exceeded" is an error that occurs when a function or operation tries to execute too many nested...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found