start throwing errors when parsing jsonl

This commit is contained in:
Ben Irvin 2023-01-30 15:09:05 +01:00
parent 26e044a58b
commit 546b6acc00
2 changed files with 5 additions and 2 deletions

View File

@ -60,7 +60,7 @@
"@types/koa": "2.13.4",
"@types/semver": "7.3.13",
"@types/stream-chain": "2.0.1",
"@types/stream-json": "1.7.2",
"@types/stream-json": "1.7.3",
"@types/tar": "6.1.3",
"@types/tar-stream": "2.2.2",
"@types/uuid": "9.0.0",

View File

@ -190,7 +190,9 @@ class LocalFileSourceProvider implements ISourceProvider {
async onentry(entry) {
const transforms = [
// JSONL parser to read the data chunks one by one (line by line)
parser(),
parser({
checkErrors: true,
}),
// The JSONL parser returns each line as key/value
(line: { key: string; value: object }) => line.value,
];
@ -213,6 +215,7 @@ class LocalFileSourceProvider implements ISourceProvider {
return outStream;
}
// For collecting an entire JSON file then parsing it, not for streaming JSONL
async #parseJSONFile<T extends object>(fileStream: Readable, filePath: string): Promise<T> {
return new Promise<T>((resolve, reject) => {
pipeline(