Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
On updating typesense database I often get the following error:
SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at (./node_modules/typesense/src/Typesense/Documents.ts:355:26)
at Array.map ()
at Documents. (./node_modules/typesense/src/Typesense/Documents.ts:355:10)
at step (./node_modules/typesense/lib/Typesense/Documents.js:48:23)
at Object.next (./node_modules/typesense/lib/Typesense/Documents.js:29:53)
at fulfilled (./node_modules/typesense/lib/Typesense/Documents.js:20:58)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Here is the diff that solved my problem:
diff --git a/node_modules/typesense/src/Typesense/Documents.ts b/node_modules/typesense/src/Typesense/Documents.ts
index b4ba7b3..1679569 100644
--- a/node_modules/typesense/src/Typesense/Documents.ts
+++ b/node_modules/typesense/src/Typesense/Documents.ts
@@ -352,6 +352,7 @@ export default class Documents<T extends DocumentSchema = object>
if (Array.isArray(documents)) {
const resultsInJSONFormat = resultsInJSONLFormat
.split("\n")
+ .filter((r) => r.trim() !== "")
.map((r) => JSON.parse(r)) as ImportResponse[];
const failedItems = resultsInJSONFormat.filter(
(r) => r.success === false,
This issue body was partially generated by patch-package.
Please consider to apply this patch!
Thank you in advance,
Tom