natergj / excel4node

Node module to allow for easy Excel file creation
MIT License
1.38k stars 215 forks source link

Call to worksheet API generates RangeError: maximum call stack size exceeded #253

Closed jusopi closed 6 years ago

jusopi commented 6 years ago

Describe the bug Every call to the worksheet API to write to a cell, both complex and simple strings generates the following error:

RangeError: Maximum call stack size exceeded

As you can see by the below error messages, the call stacks are different. Not sure if that's helpful or not.

To Reproduce Enter the node command line $:node then try the following code:

> xl = require('excel4node')
> let wb = new xl.Workbook()
undefined
> let ws = wb.addWorksheet('test')
undefined
> ws.cell(1, 1).string([12, 234, 435, 123])
RangeError: Maximum call stack size exceeded
    at stylizeNoColor (util.js:351:24)
    at formatPrimitive (util.js:602:12)
    at formatValue (util.js:365:12)
    at formatProperty (util.js:801:11)
    at formatObject (util.js:617:17)
    at formatValue (util.js:579:18)
    at formatProperty (util.js:801:11)
    at formatArray (util.js:699:17)
    at formatValue (util.js:579:18)
    at formatProperty (util.js:801:11)
> ws.cell(1, 1).string('fooo')
RangeError: Maximum call stack size exceeded
    at inspect (util.js:262:15)
    at format (util.js:158:14)
    at Console.log (console.js:130:21)
    at SimpleLogger.inspect (/Users/jopitz/Dev/Workspaces/Cisco/sync-xdb/node_modules/excel4node/distribution/lib/logger.js:38:35)
    at formatValue (util.js:400:38)
    at formatProperty (util.js:801:11)
    at formatObject (util.js:617:17)
    at formatValue (util.js:579:18)
    at formatProperty (util.js:801:11)
    at formatArray (util.js:699:17)

Expected behavior A call to ws.cell(1,1).string('foo') should not generate an error

Environment (please complete the following information):

Additional context Add any other context about the problem here. Log entries related to the issue are good things.

natergj commented 6 years ago

@jusopi, are you only seeing this in the node interpreter? If you put your code into a script.js file and then run node script.js does everything work? It looks like the node interpreter is trying to format the result of the ws.cell(1, 1).string('foo')call in order to print it to the console and the max call stack size exceeded error is coming from the formatting call, not the excel4node library. I can try to update the library to work directly in the interpreter, but would consider it a low priority.

jusopi commented 6 years ago

I originally tried this from running node script.js with the same results. The first code I posted was after many failed attempts getting a script to run with the same code.

jusopi commented 6 years ago

I figured out the script based issue: I was using the postgres node library and not closing the process by calling pool.end() so there was a process hanging out which locked out excel4node from accessing the process pool.

The CLI based version.... I haven't resolved nor does it need resolving from my end, although I do see it being a bonus for testing purposes.