Skip to content

FILE ENDED error when trying to parse excel file #86

Description

@faryalzuberi

I have deployed my code on an Azure App Service container that is running node version v12.16.3. My code works perfectly on my local machine and I am able to parse the same excel file. However on my production environment on Azure I run into this error. The parsing succeeds on every 6th/7th attempt on average.

2020-08-18T08:32:26.341702094Z Error: FILE_ENDED
2020-08-18T08:32:26.342260891Z     at Parse.pull (/node_modules/read-excel-file/node_modules/unzipper/lib/PullStream.js:80:28)
2020-08-18T08:32:26.342421390Z     at Parse.emit (events.js:310:20)
2020-08-18T08:32:26.344061183Z     at Parse.<anonymous> (/node_modules/read-excel-file/node_modules/unzipper/lib/PullStream.js:20:10)
2020-08-18T08:32:26.344410281Z     at Parse.emit (events.js:322:22)
2020-08-18T08:32:26.344805879Z     at finishMaybe (_stream_writable.js:639:14)
2020-08-18T08:32:26.344834579Z     at endWritable (_stream_writable.js:656:3)
2020-08-18T08:32:26.345403076Z     at Parse.Writable.end (_stream_writable.js:595:5)
2020-08-18T08:32:26.345778374Z     at ReadStream.onend (_stream_readable.js:660:10)
2020-08-18T08:32:26.346147072Z     at Object.onceWrapper (events.js:416:28)
2020-08-18T08:32:26.346483171Z     at ReadStream.emit (events.js:322:22)
2020-08-18T08:32:26.346493971Z     at endReadableNT (_stream_readable.js:1187:12)
2020-08-18T08:32:26.346961268Z     at processTicksAndRejections (internal/process/task_queues.js:84:21)

read-excel-file v4.0.7
unzipper version v0.9.15

async function parseFileAsJSONArray(filePath) {
    try {
        return await readXlsxFile(filePath).then((rows) => {
            return rows.map((col) => {
                return col.filter((data) => {
                    return data != null;
                })
            })
        });
    } catch (e) {
        console.log(e);
        return null;
    }

}

router.post('/uploadFile', upload.single("data"), functions.checkRouteSecurity, async (req, res) => {

    if (!req.file) return res.send({ success: false, message: "No file provided" });
    var dataArray = await parseFileAsJSONArray(req.file.path);
    fs.unlink(req.file.path, () => { console.log('deleted file ' + req.file.path) }); // delete file
    if (!(dataArray && dataArray.length > 0)) return res.send({ success: false, message: "Error. Could not parse file" });
    else {
     ...
        res.send(response);
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions