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

Uncaught errors when opening a bad CSV file #86

Closed
xqin1 opened this issue May 6, 2022 · 4 comments
Closed

Uncaught errors when opening a bad CSV file #86

xqin1 opened this issue May 6, 2022 · 4 comments

Comments

@xqin1
Copy link

xqin1 commented May 6, 2022

When opening a bad CSV file, it creates Uncaught TypeError and crashes the app, and isn't catchable with a try-catch.

 Uncaught TypeError: Cannot read property 'forEach' of undefined
      at /Users/xiaoming/Documents/projects/fcc/FCC-BDC-SDI-Backend/src/node_modules/ogr2ogr/modules/csv.js:44:13
      at /Users/xiaoming/Documents/projects/fcc/FCC-BDC-SDI-Backend/src/node_modules/ogr2ogr/modules/util.js:64:5
      at /Users/xiaoming/Documents/projects/fcc/FCC-BDC-SDI-Backend/src/node_modules/ogr2ogr/modules/csv.js:34:7
      at ReadStream.<anonymous> (node_modules/ogr2ogr/modules/util.js:64:5)
      at ReadStream.<anonymous> (node_modules/ogr2ogr/modules/csv.js:23:10)
      at addChunk (internal/streams/readable.js:309:12)
      at readableAddChunk (internal/streams/readable.js:284:9)
      at ReadStream.Readable.push (internal/streams/readable.js:223:10)
      at internal/fs/streams.js:226:14
      at FSReqCallback.wrapper [as oncomplete] (fs.js:539:5)

Code:

           await ogr2ogr(filePath)
                .format('PostgreSQL')
                .timeout(1200000)
                .options(options)
                .destination(connection)
                .promise();

The process will crash with the uncaught error, instead of catching it in the error event. This is with V2,
invalid_ogr_error.csv

@wavded
Copy link
Owner

wavded commented May 7, 2022

It appears you are on an old version of the software, have you tried this with the latest release?

@xqin1
Copy link
Author

xqin1 commented May 7, 2022

The code is on production and it'd be hard to upgrade to the latest version. If the new version fixes the issue, would it be possible to backport to V2?
thanks

@wavded
Copy link
Owner

wavded commented May 7, 2022

Unfortunately the new version is a complete rewrite, so backporting would not be possible.

@xqin1
Copy link
Author

xqin1 commented May 7, 2022

I don't see the issue on V3.1. We'll upgrade to the new version. Again, thanks for the excellent work.

close.

@xqin1 xqin1 closed this as completed May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants