audreyt / ethercalc

Node.js port of Multi-user SocialCalc
https://ethercalc.net
Other
2.95k stars 527 forks source link

When trying to export in Excel format: Error: Can't set headers after they are sent. #626

Open viniciuscb opened 6 years ago

viniciuscb commented 6 years ago

The daemon stops completely when an user tries to download the spreadsheet in excel format: (using Debian 9.4, installed using npm i -g ethercalc) version: 0.20180611.0

> tail -f /var/log/syslog

Jun 28 11:34:38 rios01 ethercalc[21483]: /usr/lib/node_modules/ethercalc/node_modules/redis/index.js:602
Jun 28 11:34:38 rios01 ethercalc[21483]:                 throw err;
Jun 28 11:34:38 rios01 ethercalc[21483]:                 ^
Jun 28 11:34:38 rios01 ethercalc[21483]: Error: Can't set headers after they are sent.
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:356:11)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ServerResponse.res.setHeader (/usr/lib/node_modules/ethercalc/node_modules/connect/lib/patch.js:133:22)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ServerResponse.res.set.res.header (/usr/lib/node_modules/ethercalc/node_modules/express/lib/response.js:578:10)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ServerResponse.res.contentType.res.type (/usr/lib/node_modules/ethercalc/node_modules/express/lib/response.js:447:15)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at /usr/lib/node_modules/ethercalc/main.js:176:32
Jun 28 11:34:38 rios01 ethercalc[21483]:     at try_callback (/usr/lib/node_modules/ethercalc/node_modules/redis/index.js:592:9)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at RedisClient.return_reply (/usr/lib/node_modules/ethercalc/node_modules/redis/index.js:685:13)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ReplyParser.<anonymous> (/usr/lib/node_modules/ethercalc/node_modules/redis/index.js:321:14)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at emitOne (events.js:96:13)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ReplyParser.emit (events.js:188:7)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ReplyParser.send_reply (/usr/lib/node_modules/ethercalc/node_modules/redis/lib/parser/javascript.js:300:10)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at ReplyParser.execute (/usr/lib/node_modules/ethercalc/node_modules/redis/lib/parser/javascript.js:203:22)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at RedisClient.on_data (/usr/lib/node_modules/ethercalc/node_modules/redis/index.js:547:27)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at Socket.<anonymous> (/usr/lib/node_modules/ethercalc/node_modules/redis/index.js:102:14)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at emitOne (events.js:96:13)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at Socket.emit (events.js:188:7)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at readableAddChunk (_stream_readable.js:176:18)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at Socket.Readable.push (_stream_readable.js:134:10)
Jun 28 11:34:38 rios01 ethercalc[21483]:     at TCP.onread (net.js:559:20)
Jun 28 11:34:38 rios01 systemd[1]: ethercalc.service: Main process exited, code=exited, status=1/FAILURE
viniciuscb commented 6 years ago

@alantygel @dtygel

eddyparkinson commented 6 years ago

thanks for posting the error details.

Looks to work here: https://ethercalc.org/=eddymulti

Also my local version works.

Looks like this line: https://github.com/audreyt/ethercalc/blob/master/main.js#L176 So the issue is with setting HTML headers.

Does it happen all the time, regardless of what is in the spreadsheet?

viniciuscb commented 6 years ago

It is happening only in multi-sheet documents. I've tried with empty and non-empty spreadsheets, and it continues to happen. We are running it on port 9000.

viniciuscb commented 6 years ago

the calc url is here: https://rios.org.br:9000 . If you want to do some testing, we can arrange some time to be together online, as when you try to export the sheet in excel, the daemon will stop, and I will have to restart it manually.

eddyparkinson commented 6 years ago

Try a clean install from the git repo?

Only your version looks to have a problem. Your version is different from https://ethercalc.org/ and my local version. Why is that?

alantygel commented 6 years ago

Hi @eddyparkinson eddy thanks for the answer, but even from a fresh install from git the problem still occurs.

What we found out is the following:

The same code is running, the difference lies at the creation the document. Any thoughts?

ps: the xls and ods export buttons are hidden (css display:none)

eddyparkinson commented 6 years ago

I am not sure what the problem is, i did find 1 error:

Error at https://github.com/audreyt/ethercalc/blob/master/manifest.appcache#L20

Looks like it needs a recompile

the Error is in the browser console: Application Cache Error event: Resource fetch failed (404) https://rios.org.br:9000/static/dist/ods.js

maybe someone made a bad commit that did not get caught.

brecke commented 5 years ago

@eddyparkinson have you found a workaround for that?

eddyparkinson commented 5 years ago

ods.js in manifest.appcache but not static/dist

update this looks like an unrelated error message. I renamed ods.js and all worked still.

missing file. static/dist/ods.js

it is in both of: https://ethercalc.org/static/dist/ods.js http://sheet.cellmaster.com.au/static/dist/ods.js

but not here: https://rios.org.br:9000/static/dist/ods.js

It did exist here: https://github.com/audreyt/ethercalc/tree/e442a5ab337f7503c009b791b93ebe4091c13408/static/dist

Not sure why it was removed.

I am not sure if this is related to the crash described above.

I suspect ods.js needs re-adding, or removing from https://github.com/audreyt/ethercalc/blob/master/manifest.appcache#L20

@audreyt do you know why ods.js is in the manifest.appcache but not in static/dist

eddyparkinson commented 5 years ago

update - ods.js in manifest.appcache

this looks like an unrelated error message. I renamed ods.js and all worked fine. Looks like ods.js is not needed.

grinapo commented 4 years ago

For me if the name starts with "=" it breaks. 0001.ods works =0001.ods breaks

isn't someone thinks it's a header? like something=0001.ods

R4wd0g commented 3 years ago

I'm facing the same issue. I've been looking for a fix for a long time, but i can't solve by myself. I would like to ask you sirs to help please. Thanks in advance.

"Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client "

15376667309 commented 2 years ago

I'm facing the same issue

gamepoll commented 9 months ago

No response from "http://rios.org.br:9000/" ..... Is "http://rios.org.br:9000/" still up and running ?

gamepoll commented 3 months ago

No response from "http://rios.org.br:9000/" ..... Cannot run any testing there. Is it still up and running ?

gamepoll commented 1 month ago

No response from "http://rios.org.br:9000/" ..... Is "http://rios.org.br:9000/" still up and running ?