Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning when importing a file with unknown (or no) extension #3710

Closed
YSelfTool opened this issue Mar 14, 2020 · 5 comments
Labels
async-migration Migration from callback-style programming to async functions Export/Import Minor Bug

Comments

@YSelfTool
Copy link

YSelfTool commented Mar 14, 2020

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.

@JohnMcLear
Copy link
Member

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.

@JohnMcLear
Copy link
Member

@raybellis
Copy link
Contributor

raybellis commented Mar 17, 2020

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

@raybellis
Copy link
Contributor

raybellis commented Mar 17, 2020

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

@muxator muxator changed the title UnhandledPromiseRejectionWarning when importing a file without file extension UnhandledPromiseRejectionWarning when importing a file with unknown (or no) extension Mar 17, 2020
@muxator muxator added Export/Import async-migration Migration from callback-style programming to async functions labels Mar 17, 2020
@muxator
Copy link
Contributor

muxator commented Mar 17, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async-migration Migration from callback-style programming to async functions Export/Import Minor Bug
Projects
None yet
Development

No branches or pull requests

4 participants