ethercalc icon indicating copy to clipboard operation
ethercalc copied to clipboard

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

Open viniciuscb opened this issue 7 years ago • 16 comments

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 avatar Jun 28 '18 14:06 viniciuscb

@alantygel @dtygel

viniciuscb avatar Jun 28 '18 14:06 viniciuscb

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?

eddyparkinson avatar Jun 29 '18 02:06 eddyparkinson

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 avatar Jun 29 '18 11:06 viniciuscb

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.

viniciuscb avatar Jun 29 '18 11:06 viniciuscb

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?

eddyparkinson avatar Jul 02 '18 01:07 eddyparkinson

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:

  • if a document is created from here https://rios.org.br:9000/, or directly typing the link (e.g. https://rios.org.br:9000/=minhaplanilha) , it works.
  • if a document is created from NextCloud using ownpad, the bug happens (e.g. https://rios.org.br:9000/=Z9jzcz8pZrVjhTWg)

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)

alantygel avatar Jul 02 '18 13:07 alantygel

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.

eddyparkinson avatar Jul 05 '18 08:07 eddyparkinson

@eddyparkinson have you found a workaround for that?

brecke avatar Apr 26 '19 09:04 brecke

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 avatar Apr 27 '19 00:04 eddyparkinson

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.

eddyparkinson avatar Apr 27 '19 00:04 eddyparkinson

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

grinapo avatar Mar 13 '20 12:03 grinapo

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 "

R4wd0g avatar Aug 07 '20 16:08 R4wd0g

I'm facing the same issue

15376667309 avatar Nov 13 '21 14:11 15376667309

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

gamepoll avatar Sep 20 '23 08:09 gamepoll

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

gamepoll avatar Mar 13 '24 09:03 gamepoll

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

gamepoll avatar Jun 06 '24 10:06 gamepoll