Maximum call stack size exceeded
See original GitHub issuein 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:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hm. I will try to look later today.
I added a better warning for cases like this
84c0aff