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

FILE ENDED error when trying to parse excel file #86

Open
faryalzuberi opened this issue Aug 18, 2020 · 3 comments
Open

FILE ENDED error when trying to parse excel file #86

faryalzuberi opened this issue Aug 18, 2020 · 3 comments
Labels
wontfix This will not be worked on

Comments

@faryalzuberi
Copy link

faryalzuberi commented Aug 18, 2020

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);
    }
});
@remeoj
Copy link

remeoj commented Apr 16, 2021

I think this has something to do with using the await function, I'm trying to figure this out now too

@catamphetamine catamphetamine added the wontfix This will not be worked on label Oct 7, 2021
@alvaroaac
Copy link

I think this has something to do with using the await function, I'm trying to figure this out now too

I have changed my code to use only promises with .then and this error still pops up from time to time. It doesn't happen all the time, which is actually more frustrating as it makes it super hard to debug.

@rvpanoz
Copy link

rvpanoz commented Oct 24, 2021

I think this has something to do with using the await function, I'm trying to figure this out now too

I have changed my code to use only promises with .then and this error still pops up from time to time. It doesn't happen all the time, which is actually more frustrating as it makes it super hard to debug.

I am getting the same error, it's true - it doesn't pops up all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants