mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-08 14:39:02 +08:00
Added try catch to message handler
This commit is contained in:
parent
3e60f175bb
commit
63bbeadbfc
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mendable/firecrawl-js",
|
||||
"version": "1.9.7",
|
||||
"version": "1.9.8",
|
||||
"description": "JavaScript SDK for Firecrawl API",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -1009,14 +1009,21 @@ export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
||||
this.ws.close();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const msg = JSON.parse(ev.data) as Message;
|
||||
messageHandler(msg);
|
||||
} catch (error) {
|
||||
console.error("Error on message", error);
|
||||
}
|
||||
}).bind(this);
|
||||
|
||||
this.ws.onclose = ((ev: CloseEvent) => {
|
||||
try {
|
||||
const msg = JSON.parse(ev.reason) as Message;
|
||||
messageHandler(msg);
|
||||
} catch (error) {
|
||||
console.error("Error on close", error);
|
||||
}
|
||||
}).bind(this);
|
||||
|
||||
this.ws.onerror = ((_: Event) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user