Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

don't crash for bad json

phil 9969945f 72772d6c

+17 -4
+17 -4
jetstream/src/lib.rs
··· 425 425 Some(Ok(message)) => { 426 426 match message { 427 427 Message::Text(json) => { 428 - let event: JetstreamEvent = serde_json::from_str(&json) 429 - .map_err(JetstreamEventError::ReceivedMalformedJSON)?; 428 + let event: JetstreamEvent = match serde_json::from_str(&json) { 429 + Ok(ev) => ev, 430 + Err(e) => { 431 + log::warn!( 432 + "failed to parse json: {e:?} (from {})", 433 + json.get(..24).unwrap_or(&json) 434 + ); 435 + continue; 436 + } 437 + }; 430 438 let event_cursor = event.cursor; 431 439 432 440 if let Some(last) = last_cursor { ··· 456 464 ) 457 465 .map_err(JetstreamEventError::CompressionDictionaryError)?; 458 466 459 - let event: JetstreamEvent = serde_json::from_reader(decoder) 460 - .map_err(JetstreamEventError::ReceivedMalformedJSON)?; 467 + let event: JetstreamEvent = match serde_json::from_reader(decoder) { 468 + Ok(ev) => ev, 469 + Err(e) => { 470 + log::warn!("failed to parse json: {e:?}"); 471 + continue; 472 + } 473 + }; 461 474 let event_cursor = event.cursor; 462 475 463 476 if let Some(last) = last_cursor {