Skip to content

Commit

Permalink
🐛 models: Fix crash on api error (#137)
Browse files Browse the repository at this point in the history
* 🐛 models: Fix crash on api error

* 🐛 tests: Increase test timeout
  • Loading branch information
lowczarc authored Apr 30, 2024
1 parent 4c5b07e commit d5019a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,11 @@ function stream(
ws.onopen = () => ws.send(JSON.stringify(requestBody));
ws.onmessage = (data: unknown) => onMessage(data, resultStream);
ws.onclose = () => resultStream.push(null);
ws.onerror = () => resultStream.push(null);
resultStream.stop = () => {
ws.send("STOP");
};
})();
})().catch(console.error);
return resultStream;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polyfire-js",
"version": "0.2.58",
"version": "0.2.59",
"main": "index.js",
"types": "index.d.ts",
"author": "Lancelot Owczarczak <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions tests/generation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ test(

expect(message).toBe("banana42");
}),
10000,
);

0 comments on commit d5019a5

Please sign in to comment.