mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
import: Resolve error handling import causes instance crash
This commit is contained in:
parent
4497d37af9
commit
addb9b957a
1 changed files with 13 additions and 1 deletions
|
@ -73,6 +73,18 @@ async function doImport(req, res, padId)
|
|||
form.keepExtensions = true;
|
||||
form.uploadDir = tmpDirectory;
|
||||
form.maxFileSize = settings.importMaxFileSize;
|
||||
|
||||
// Ref: https://github.com/node-formidable/formidable/issues/469
|
||||
// Crash in Etherpad was Uploading Error: Error: Request aborted
|
||||
// [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
|
||||
form.onPart = part => {
|
||||
form.handlePart(part);
|
||||
if (part.filename !== undefined) {
|
||||
form.openedFiles[form.openedFiles.length - 1]._writeStream.on('error', err => {
|
||||
form.emit('error', err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// locally wrapped Promise, since form.parse requires a callback
|
||||
let srcFile = await new Promise((resolve, reject) => {
|
||||
|
@ -84,7 +96,7 @@ async function doImport(req, res, padId)
|
|||
}
|
||||
|
||||
// I hate doing indexOf here but I can't see anything to use...
|
||||
if (err.stack.indexOf("maxFileSize") !== -1) {
|
||||
if (err && err.stack && err.stack.indexOf("maxFileSize") !== -1) {
|
||||
reject("maxFileSize");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue