Etherpad-lite: UnhandledPromiseRejectionWarning when importing a file with unknown (or no) extension

Created on 14 Mar 2020  ·  5Comments  ·  Source: ether/etherpad-lite

This happens in 1.8:

[ERROR] console - (node:27731) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
   at makeCallback (fs.js:136:11)
   at Object.rename (fs.js:578:14)
   at doImport (/opt/etherpad-lite/src/node/handler/ImportHandler.js:104:16)
   at process._tickCallback (internal/process/next_tick.js:68:7)

This happens when importing a file without known extension in the file name (e.g. no extension at all). As a workaround, you have to set the file name and let it end with an extension, e.g. .txt.


Edit by @muxator: this happens not only when no extension is given, but for every unknown extension (including none) when allowUnknownFileEnds in settings.json is true. Changed the title accordingly.

ExporImport Minor Bug async-migration

Most helpful comment

Fixed pulling in #3722 by @tudorconstantin.
Thanks everyone.

All 5 comments

Ah okay so this was due to the async work cc @raybellis

https://github.com/ether/etherpad-lite/blob/develop/src/node/handler/ImportHandler.js#L104

This is the offending line, if you upload a whatever.md etc to Etherpad you will see this error.

Do you have time to take a look @raybellis

For me for plugin development I just hack around it.

https://github.com/ether/etherpad-lite/pull/3718/files is my hacky workaround. @raybellis

The non-hacky fix is to replace the call to fs.rename(src, dst, cb) with await fsp_rename(src, dst)

Ah, I see @tudorconstantin already beat me to it :)

Fixed pulling in #3722 by @tudorconstantin.
Thanks everyone.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JohnMcLear picture JohnMcLear  ·  9Comments

alekso87 picture alekso87  ·  6Comments

dessalines picture dessalines  ·  7Comments

wbt picture wbt  ·  7Comments

zeer15398376 picture zeer15398376  ·  9Comments