Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(kafka): tokio spawn rework (#4803)
Will Hutchinson86e778648769
diff --git a/crates/channels/src/domain/side_effects.rs b/crates/channels/src/domain/side_effects.rsindex 724030e253..08a9a90ec8 100644--- a/crates/channels/src/domain/side_effects.rs+++ b/crates/channels/src/domain/side_effects.rs@@ -612,7 +612,6 @@ wherelet _ = self.macro_event_broker.send_event(&broker_event)- .await.inspect_err(|e| {tracing::error!(error=?e, "failed to publish channel event");});diff --git a/crates/channels/src/domain/side_effects/test.rs b/crates/channels/src/domain/side_effects/test.rsindex eb38e5cdd1..34fa4a7348 100644--- a/crates/channels/src/domain/side_effects/test.rs+++ b/crates/channels/src/domain/side_effects/test.rs@@ -1046,17 +1046,20 @@ struct PublishedEvent {}impl MacroEventBroker for TestEventBroker {- async fn send_event<E: macro_event_broker::MacroEvent + ?Sized>(+ fn send_event<E: macro_event_broker::MacroEvent + ?Sized>(&self,event: &E,- ) -> Result<(), macro_event_broker::EventBrokerError> {+ ) -> Result<+ tokio::task::JoinHandle<Result<(), macro_event_broker::EventBrokerError>>,+ macro_event_broker::EventBrokerError,+ > {use macro_event_topics::Topic as _;self.published.lock().unwrap().push(PublishedEvent {topic: event.topic().as_str().to_string(),key: event.key().to_string(),envelope: serde_json::to_value(event.event())?,});- Ok(())+ Ok(tokio::spawn(async { Ok(()) }))}}@@ -1064,10 +1067,13 @@ impl MacroEventBroker for TestEventBroker {struct FailingEventBroker;impl MacroEventBroker for FailingEventBroker {- async fn send_event<E: macro_event_broker::MacroEvent + ?Sized>(+ fn send_event<E: macro_event_broker::MacroEvent + ?Sized>(&self,_event: &E,- ) -> Result<(), macro_event_broker::EventBrokerError> {+ ) -> Result<+ tokio::task::JoinHandle<Result<(), macro_event_broker::EventBrokerError>>,+ macro_event_broker::EventBrokerError,+ > {Err(macro_event_broker::EventBrokerError::Publish("broker unavailable".to_string(),))diff --git a/crates/documents/src/domain/service.rs b/crates/documents/src/domain/service.rsindex 22e4aca4a7..bdd62fccf5 100644--- a/crates/documents/src/domain/service.rs+++ b/crates/documents/src/domain/service.rs@@ -519,14 +519,10 @@ impl<}/// Publish a document lifecycle event; failures are logged and dropped.- async fn publish_document_event(&self, event: &DocumentMacroEvent) {- let _ = self- .macro_event_broker- .send_event(event)- .await- .inspect_err(|e| {- tracing::error!(error=?e, "failed to publish document event");- });+ fn publish_document_event(&self, event: &DocumentMacroEvent) {+ let _ = self.macro_event_broker.send_event(event).inspect_err(|e| {+ tracing::error!(error=?e, "failed to publish document event");+ });}}@@ -762,8 +758,7 @@ impl<actor_user_id: event_actor_user_id(entity_access_receipt.auth()),project_id,},- ))- .await;+ ));Ok(())}@@ -1080,8 +1075,7 @@ impl<sub_type: document_metadata.sub_type,created_at: document_metadata.created_at,},- ))- .await;+ ));Ok(CreateDocumentResponseData {document_response: DocumentResponse {@@ -1247,8 +1241,7 @@ impl<file_type: args.file_type,share_permission_updated,},- ))- .await;+ ));Ok(())}@@ -1504,8 +1497,7 @@ impl<project_id: new_metadata.project_id.clone(),sub_type: new_metadata.sub_type,},- ))- .await;+ ));Ok(DocumentResponse {document_metadata: DocumentResponseMetadataWithContent::new(diff --git a/crates/documents/src/domain/service/tests.rs b/crates/documents/src/domain/service/tests.rsindex 1095ee1255..90f3ac9f71 100644--- a/crates/documents/src/domain/service/tests.rs+++ b/crates/documents/src/domain/service/tests.rs@@ -322,13 +322,16 @@ impl TestEventBroker {}impl MacroEventBroker for TestEventBroker {- async fn send_event<E: MacroEvent + ?Sized>(&self, event: &E) -> Result<(), EventBrokerError> {+ fn send_event<E: MacroEvent + ?Sized>(+ &self,+ event: &E,+ ) -> Result<tokio::task::JoinHandle<Result<(), EventBrokerError>>, EventBrokerError> {self.published.lock().unwrap().push(PublishedEvent {topic: event.topic().as_str(),key: event.key().to_string(),payload: serde_json::to_value(event.event())?,});- Ok(())+ Ok(tokio::spawn(async { Ok(()) }))}}diff --git a/crates/email/src/domain/service/mod.rs b/crates/email/src/domain/service/mod.rsindex 8ac8b7cd0f..3bbae220dd 100644--- a/crates/email/src/domain/service/mod.rs+++ b/crates/email/src/domain/service/mod.rs@@ -84,14 +84,13 @@ impl<T, U, E, CS, Eam, B> EmailServiceImpl<T, U, E, CS, Eam, B> {/// Publish an email event to the `macro.email` topic, logging and/// dropping failures — event emission must never fail the operation.- pub(crate) async fn publish_email_event(&self, event: &EmailMacroEvent)+ pub(crate) fn publish_email_event(&self, event: &EmailMacroEvent)whereB: MacroEventBroker,{let _ = self.macro_event_broker.send_event(event)- .await.inspect_err(|e| tracing::error!(error=?e, "failed to publish email macro event"));}}@@ -355,8 +354,7 @@ whereprevious_project_id: old_project_id.clone(),project_id: project_id.map(|p| p.to_string()),},- ))- .await;+ ));}Ok(None) => tracing::warn!(%thread_id,diff --git a/crates/email/src/domain/service/send.rs b/crates/email/src/domain/service/send.rsindex e3da4b4569..0daca42e1b 100644--- a/crates/email/src/domain/service/send.rs+++ b/crates/email/src/domain/service/send.rs@@ -55,8 +55,7 @@ wherescheduled_send_at: send_time,is_scheduled: false,},- ))- .await;+ ));Ok(created)}diff --git a/crates/email/src/domain/service/thread_labels.rs b/crates/email/src/domain/service/thread_labels.rsindex fe549e3762..434f298a8d 100644--- a/crates/email/src/domain/service/thread_labels.rs+++ b/crates/email/src/domain/service/thread_labels.rs@@ -119,8 +119,7 @@ where// Publish semantic macro.email events now that the optimistic DB// writes are committed. The provider echo of this change finds no// label diff during inbox sync, so each change publishes only once.- self.publish_thread_label_events(link, thread_id, &label, add, &cancelled_send_ids)- .await;+ self.publish_thread_label_events(link, thread_id, &label, add, &cancelled_send_ids);// Enqueue Gmail API calls via the gmail_ops worker (provider messages only)let provider_messages: Vec<(Uuid, String)> = messages@@ -162,7 +161,7 @@ where/// [`EmailMacroEvent::thread_label_change`]). Scheduled sends cancelled/// by trashing publish `message_send_cancelled`. Actor is not tracked on/// this path — the inbox owner is on `link`.- async fn publish_thread_label_events(+ fn publish_thread_label_events(&self,link: &Link,thread_id: Uuid,@@ -185,7 +184,7 @@ where);if let Some(event) = event {- self.publish_email_event(&event).await;+ self.publish_email_event(&event);}for message_id in cancelled_send_ids {@@ -198,8 +197,7 @@ wherethread_id,reason: SendCancelReason::ThreadTrashed,},- ))- .await;+ ));}}}diff --git a/crates/macro_event_broker/Cargo.toml b/crates/macro_event_broker/Cargo.tomlindex da942d0d74..e332bb7760 100644--- a/crates/macro_event_broker/Cargo.toml+++ b/crates/macro_event_broker/Cargo.toml@@ -26,11 +26,11 @@ rdkafka = { workspace = true, optional = true }serde = { workspace = true }serde_json = { workspace = true }thiserror = { workspace = true }-tokio = { workspace = true, features = ["macros"], optional = true }+tokio = { workspace = true, features = ["macros", "time"], optional = true }tracing = { workspace = true }uuid = { workspace = true }workspace-hack = { version = "0.1", path = "../workspace-hack" }macro_event_topics = { path = "../macro_event_topics" }[dev-dependencies]-tokio = { workspace = true }+tokio = { workspace = true, features = ["test-util", "time"] }diff --git a/crates/macro_event_broker/examples/example_event.rs b/crates/macro_event_broker/examples/example_event.rsindex a118059080..3f001ae6db 100644--- a/crates/macro_event_broker/examples/example_event.rs+++ b/crates/macro_event_broker/examples/example_event.rs@@ -137,7 +137,10 @@ pub async fn main() -> Result<(), EventBrokerError> {},);- service.send_event(&event).await?;+ service+ .send_event(&event)?+ .await+ .expect("event publish task should complete")?;Ok(())}diff --git a/crates/macro_event_broker/src/domain/models.rs b/crates/macro_event_broker/src/domain/models.rsindex f8062fa1ba..9ac7dd6af4 100644--- a/crates/macro_event_broker/src/domain/models.rs+++ b/crates/macro_event_broker/src/domain/models.rs@@ -116,6 +116,12 @@ pub enum EventBrokerError {/// The broker rejected or failed to deliver the message.#[error("failed to publish event: {0}")]Publish(String),+ /// Publishing did not complete within the configured timeout.+ #[error("event publish timed out after {timeout:?}")]+ PublishTimeout {+ /// Maximum duration allowed for publication.+ timeout: std::time::Duration,+ },/// An otherwise-unclassified internal error.#[error("internal event broker error: {0:?}")]Internal(rootcause::Report),diff --git a/crates/macro_event_broker/src/domain/ports.rs b/crates/macro_event_broker/src/domain/ports.rsindex a24f43dc53..285b27f1a9 100644--- a/crates/macro_event_broker/src/domain/ports.rs+++ b/crates/macro_event_broker/src/domain/ports.rs@@ -10,12 +10,17 @@ use crate::domain::models::{EventBrokerError, MacroEvent};////// Implemented by [`MacroEventBrokerService`](crate::domain::service::MacroEventBrokerService).pub trait MacroEventBroker: Send + Sync + 'static {- /// Serialize `event` to JSON and publish it to the topic declared by its typed payload,- /// keyed by [`MacroEvent::key`].+ /// Serialize `event` to JSON and schedule it for publication to the topic declared by its+ /// typed payload, keyed by [`MacroEvent::key`].+ ///+ /// Serialization errors are returned immediately. Publication runs in a spawned task, whose+ /// [`tokio::task::JoinHandle`] can be awaited when the caller needs to wait for completion and+ /// inspect publisher failures or timeouts. Task errors are also logged so callers may still+ /// use this method for fire-and-forget publication.fn send_event<E: MacroEvent + ?Sized>(&self,event: &E,- ) -> impl Future<Output = Result<(), EventBrokerError>> + Send;+ ) -> Result<tokio::task::JoinHandle<Result<(), EventBrokerError>>, EventBrokerError>;}/// Outbound port: the boundary to the underlying message broker (e.g. Kafka).diff --git a/crates/macro_event_broker/src/domain/service.rs b/crates/macro_event_broker/src/domain/service.rsindex 0f0ad727c2..65521aa0d2 100644--- a/crates/macro_event_broker/src/domain/service.rs+++ b/crates/macro_event_broker/src/domain/service.rs@@ -3,33 +3,72 @@#[cfg(test)]mod test;+use std::sync::Arc;+use std::time::Duration;+use macro_event_topics::Topic as _;+use tracing::Instrument as _;use crate::domain::models::{EventBrokerError, MacroEvent};use crate::domain::ports::{EventPublisher, MacroEventBroker};+const PUBLISH_TIMEOUT: Duration = Duration::from_secs(6);+/// Orchestrates serializing events and handing them to an [`EventPublisher`].-#[derive(Clone)]pub struct MacroEventBrokerService<P: EventPublisher> {- publisher: P,+ publisher: Arc<P>,+}++impl<P: EventPublisher> Clone for MacroEventBrokerService<P> {+ fn clone(&self) -> Self {+ Self {+ publisher: Arc::clone(&self.publisher),+ }+ }}impl<P: EventPublisher> MacroEventBrokerService<P> {/// Create a new service backed by the given outbound publisher.pub fn new(publisher: P) -> Self {- Self { publisher }+ Self {+ publisher: Arc::new(publisher),+ }}}impl<P: EventPublisher> MacroEventBroker for MacroEventBrokerService<P> {#[tracing::instrument(err, skip(self, event), fields(topic = %event.topic().as_str(), key = %event.key()))]- async fn send_event<E: MacroEvent + ?Sized>(&self, event: &E) -> Result<(), EventBrokerError> {+ fn send_event<E: MacroEvent + ?Sized>(+ &self,+ event: &E,+ ) -> Result<tokio::task::JoinHandle<Result<(), EventBrokerError>>, EventBrokerError> {let topic = event.topic();- let key = event.key();- let envelope = event.event();- let payload = serde_json::to_vec(envelope)?;+ let key = event.key().to_owned();+ let payload = serde_json::to_vec(event.event())?;+ let publisher = Arc::clone(&self.publisher);+ let span = tracing::Span::current();++ let handle = tokio::spawn(+ async move {+ tokio::time::timeout(PUBLISH_TIMEOUT, publisher.publish(topic, &key, &payload))+ .await+ .map_err(|_| EventBrokerError::PublishTimeout {+ timeout: PUBLISH_TIMEOUT,+ })+ .and_then(std::convert::identity)+ .inspect_err(|error| {+ tracing::error!(+ error = ?error,+ topic = topic.as_str(),+ key = %key,+ "failed to publish event",+ );+ })+ }+ .instrument(span),+ );- self.publisher.publish(topic, key, &payload).await+ Ok(handle)}}@@ -41,7 +80,10 @@ impl<P: EventPublisher> MacroEventBroker for MacroEventBrokerService<P> {pub struct NoopMacroEventBroker;impl MacroEventBroker for NoopMacroEventBroker {- async fn send_event<E: MacroEvent + ?Sized>(&self, _event: &E) -> Result<(), EventBrokerError> {- Ok(())+ fn send_event<E: MacroEvent + ?Sized>(+ &self,+ _event: &E,+ ) -> Result<tokio::task::JoinHandle<Result<(), EventBrokerError>>, EventBrokerError> {+ Ok(tokio::spawn(async { Ok(()) }))}}diff --git a/crates/macro_event_broker/src/domain/service/test.rs b/crates/macro_event_broker/src/domain/service/test.rsindex ae2d337c76..ad42172c8e 100644--- a/crates/macro_event_broker/src/domain/service/test.rs+++ b/crates/macro_event_broker/src/domain/service/test.rs@@ -1,4 +1,9 @@-use std::sync::Mutex;+use std::future::pending;+use std::sync::{+ Arc, Mutex,+ atomic::{AtomicBool, Ordering},+};+use std::time::Duration;use macro_event_topics::{MacroExampleTopic, Topic};use serde::{Deserialize, Serialize};@@ -38,6 +43,68 @@ impl EventPublisher for RecordingPublisher {}}+struct PendingPublisher {+ started: Arc<AtomicBool>,+}++impl EventPublisher for PendingPublisher {+ async fn publish<T: Topic>(+ &self,+ _topic: T,+ _key: &str,+ _payload: &[u8],+ ) -> Result<(), EventBrokerError> {+ self.started.store(true, Ordering::SeqCst);+ pending().await+ }+}++struct PublishDropGuard {+ dropped: Arc<AtomicBool>,+}++impl Drop for PublishDropGuard {+ fn drop(&mut self) {+ self.dropped.store(true, Ordering::SeqCst);+ }+}++struct HangingPublisher {+ started: Arc<AtomicBool>,+ dropped: Arc<AtomicBool>,+}++impl EventPublisher for HangingPublisher {+ async fn publish<T: Topic>(+ &self,+ _topic: T,+ _key: &str,+ _payload: &[u8],+ ) -> Result<(), EventBrokerError> {+ self.started.store(true, Ordering::SeqCst);+ let _drop_guard = PublishDropGuard {+ dropped: Arc::clone(&self.dropped),+ };+ pending().await+ }+}++struct FailingPublisher {+ attempted: Arc<AtomicBool>,+}++impl EventPublisher for FailingPublisher {+ async fn publish<T: Topic>(+ &self,+ _topic: T,+ _key: &str,+ _payload: &[u8],+ ) -> Result<(), EventBrokerError> {+ self.attempted.store(true, Ordering::SeqCst);+ Err(EventBrokerError::Publish("test failure".to_string()))+ }+}+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]struct ExampleCreatedMetadata {name: String,@@ -89,21 +156,70 @@ impl MacroEvent for ExampleMacroEvent {}}+fn example_event() -> ExampleMacroEvent {+ ExampleMacroEvent::with_event(+ "msg-123",+ Event::with_event_id(+ Uuid::from_u128(1),+ ExampleTopicEvent::Created(ExampleCreatedMetadata {+ name: "hello".to_string(),+ count: 7,+ }),+ ),+ )+}++#[derive(Debug, Deserialize)]+struct UnserializableTopicEvent;++impl Serialize for UnserializableTopicEvent {+ fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error>+ where+ S: serde::Serializer,+ {+ Err(serde::ser::Error::custom("test serialization failure"))+ }+}++impl TopicEvent for UnserializableTopicEvent {+ type Topic = MacroExampleTopic;++ fn schema_version(&self) -> u8 {+ 1+ }+}++struct UnserializableMacroEvent {+ event: Event<UnserializableTopicEvent>,+}++impl MacroEvent for UnserializableMacroEvent {+ type EventPayload = UnserializableTopicEvent;++ fn key(&self) -> &str {+ "unserializable"+ }++ fn event(&self) -> &Event<Self::EventPayload> {+ &self.event+ }++ fn from_event(_key: String, event: Event<Self::EventPayload>) -> Self {+ Self { event }+ }+}+#[tokio::test]-async fn send_event_serializes_and_routes() {+async fn dispatch_serializes_and_routes() {let service = MacroEventBrokerService::new(RecordingPublisher::default());- let envelope = Event::with_event_id(- Uuid::from_u128(1),- ExampleTopicEvent::Created(ExampleCreatedMetadata {- name: "hello".to_string(),- count: 7,- }),- );- let event = ExampleMacroEvent::with_event("msg-123", envelope.clone());+ let event = example_event();+ let expected_payload = serde_json::to_vec(event.event()).unwrap();service.send_event(&event)+ .expect("dispatch should succeed").await+ .expect("publish task should complete").expect("publish should succeed");let calls = service.publisher.calls.lock().unwrap();@@ -111,5 +227,85 @@ async fn send_event_serializes_and_routes() {let call = &calls[0];assert_eq!(call.topic, MacroExampleTopic.as_str());assert_eq!(call.key, "msg-123");- assert_eq!(call.payload, serde_json::to_vec(&envelope).unwrap());+ assert_eq!(call.payload, expected_payload);+}++#[tokio::test]+async fn dispatch_returns_before_publish_completes() {+ let started = Arc::new(AtomicBool::new(false));+ let service = MacroEventBrokerService::new(PendingPublisher {+ started: Arc::clone(&started),+ });++ let handle = service+ .send_event(&example_event())+ .expect("dispatch should succeed");++ assert!(!started.load(Ordering::SeqCst));+ assert!(!handle.is_finished());+ tokio::task::yield_now().await;+ assert!(started.load(Ordering::SeqCst));+ handle.abort();+}++#[tokio::test(start_paused = true)]+async fn dispatch_cancels_publish_at_six_second_timeout() {+ let started = Arc::new(AtomicBool::new(false));+ let dropped = Arc::new(AtomicBool::new(false));+ let service = MacroEventBrokerService::new(HangingPublisher {+ started: Arc::clone(&started),+ dropped: Arc::clone(&dropped),+ });++ let handle = service+ .send_event(&example_event())+ .expect("dispatch should succeed");+ tokio::task::yield_now().await;+ assert!(started.load(Ordering::SeqCst));++ tokio::time::advance(Duration::from_secs(5)).await;+ tokio::task::yield_now().await;+ assert!(!dropped.load(Ordering::SeqCst));++ tokio::time::advance(Duration::from_secs(1)).await;+ let error = handle+ .await+ .expect("publish task should complete")+ .unwrap_err();+ assert!(matches!(+ error,+ EventBrokerError::PublishTimeout { timeout } if timeout == PUBLISH_TIMEOUT+ ));+ assert!(dropped.load(Ordering::SeqCst));+}++#[tokio::test]+async fn dispatch_returns_publisher_failure_from_task() {+ let attempted = Arc::new(AtomicBool::new(false));+ let service = MacroEventBrokerService::new(FailingPublisher {+ attempted: Arc::clone(&attempted),+ });++ let error = service+ .send_event(&example_event())+ .expect("dispatch should succeed before publishing")+ .await+ .expect("publish task should complete")+ .unwrap_err();++ assert!(matches!(error, EventBrokerError::Publish(message) if message == "test failure"));+ assert!(attempted.load(Ordering::SeqCst));+}++#[tokio::test]+async fn dispatch_returns_serialization_failure_without_publishing() {+ let service = MacroEventBrokerService::new(RecordingPublisher::default());+ let event = UnserializableMacroEvent {+ event: Event::with_event_id(Uuid::from_u128(2), UnserializableTopicEvent),+ };++ let error = service.send_event(&event).unwrap_err();+ assert!(matches!(error, EventBrokerError::Serialization(_)));+ tokio::task::yield_now().await;+ assert!(service.publisher.calls.lock().unwrap().is_empty());}diff --git a/services/email_service/src/api/email/drafts/scheduled/remove.rs b/services/email_service/src/api/email/drafts/scheduled/remove.rsindex 335cb601fb..50e7cb0a83 100644--- a/services/email_service/src/api/email/drafts/scheduled/remove.rs+++ b/services/email_service/src/api/email/drafts/scheduled/remove.rs@@ -119,8 +119,7 @@ pub async fn handler(thread_id,reason: SendCancelReason::Undo,}),- )- .await;+ );}Ok(StatusCode::NO_CONTENT)diff --git a/services/email_service/src/api/email/drafts/scheduled/upsert.rs b/services/email_service/src/api/email/drafts/scheduled/upsert.rsindex 2447fde17e..d1ee6a0d0f 100644--- a/services/email_service/src/api/email/drafts/scheduled/upsert.rs+++ b/services/email_service/src/api/email/drafts/scheduled/upsert.rs@@ -132,8 +132,7 @@ pub async fn handler(scheduled_send_at: request.send_time,is_scheduled: true,}),- )- .await;+ );}Ok(Json(UpsertScheduledResponse {diff --git a/services/email_service/src/api/email/init.rs b/services/email_service/src/api/email/init.rsindex eb60dc8125..b3c4f4bd33 100644--- a/services/email_service/src/api/email/init.rs+++ b/services/email_service/src/api/email/init.rs@@ -673,8 +673,7 @@ async fn init_user(is_primary: link.is_primary,connected_at: link.created_at,}),- )- .await;+ );let ps_message = BackfillPubsubMessage {backfill_operation: BackfillOperation::Init(JobScopedPayload {diff --git a/services/email_service/src/api/email/messages/labels.rs b/services/email_service/src/api/email/messages/labels.rsindex c53abb146c..308e987718 100644--- a/services/email_service/src/api/email/messages/labels.rs+++ b/services/email_service/src/api/email/messages/labels.rs@@ -256,7 +256,7 @@ pub async fn handler(EmailEventOrigin::UserAction,);if let Some(event) = event {- publish_email_event(ctx.macro_event_broker.as_ref(), &event).await;+ publish_email_event(ctx.macro_event_broker.as_ref(), &event);}}diff --git a/services/email_service/src/api/email/threads/archived.rs b/services/email_service/src/api/email/threads/archived.rsindex f0faa1c671..3ca304c01e 100644--- a/services/email_service/src/api/email/threads/archived.rs+++ b/services/email_service/src/api/email/threads/archived.rs@@ -183,8 +183,7 @@ pub async fn archived_handler(archived: is_archiving,origin: EmailEventOrigin::UserAction,}),- )- .await;+ );// Enqueue one gmail_ops message per provider messagelet (labels_to_add, labels_to_remove) = if is_archiving {diff --git a/services/email_service/src/api/email/threads/seen.rs b/services/email_service/src/api/email/threads/seen.rsindex 6dfa2aee8e..e7f391a4af 100644--- a/services/email_service/src/api/email/threads/seen.rs+++ b/services/email_service/src/api/email/threads/seen.rs@@ -172,8 +172,7 @@ pub async fn seen_handler(is_read: true,origin: EmailEventOrigin::UserAction,}),- )- .await;+ );// Enqueue gmail ops messages in batchlet gmail_ops_messages: Vec<_> = unread_messagesdiff --git a/services/email_service/src/pubsub/inbox_sync/operations/delete_message.rs b/services/email_service/src/pubsub/inbox_sync/operations/delete_message.rsindex 8392643427..5f9603dd64 100644--- a/services/email_service/src/pubsub/inbox_sync/operations/delete_message.rs+++ b/services/email_service/src/pubsub/inbox_sync/operations/delete_message.rs@@ -125,8 +125,7 @@ pub async fn delete_message(provider_message_id: payload.provider_message_id.clone(),thread_id: message.thread_db_id,}),- )- .await;+ );// tell FE to refresh user's inboxcg_refresh_email(diff --git a/services/email_service/src/pubsub/inbox_sync/operations/update_labels.rs b/services/email_service/src/pubsub/inbox_sync/operations/update_labels.rsindex 4a1e0dab15..ab075957ad 100644--- a/services/email_service/src/pubsub/inbox_sync/operations/update_labels.rs+++ b/services/email_service/src/pubsub/inbox_sync/operations/update_labels.rs@@ -342,7 +342,7 @@ async fn publish_label_diff_events(}for event in &events {- publish_email_event(&ctx.macro_event_broker, event).await;+ publish_email_event(&ctx.macro_event_broker, event);}}diff --git a/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs b/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rsindex 632765ffcd..6ff22d0772 100644--- a/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs+++ b/services/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs@@ -272,7 +272,7 @@ pub async fn upsert_message(received_at: event_received_at,})};- publish_email_event(&ctx.macro_event_broker, &event).await;+ publish_email_event(&ctx.macro_event_broker, &event);}handle_attachment_upload(diff --git a/services/email_service/src/pubsub/link_manager/process.rs b/services/email_service/src/pubsub/link_manager/process.rsindex 2995db88f9..3bcb3338d2 100644--- a/services/email_service/src/pubsub/link_manager/process.rs+++ b/services/email_service/src/pubsub/link_manager/process.rs@@ -247,8 +247,7 @@ async fn handle_notify_reauth_required(email_address: link.email_address.0.as_ref().to_string(),observed_at: link.last_sync_error_at.unwrap_or_else(chrono::Utc::now),}),- )- .await;+ );Ok(())}@@ -418,8 +417,7 @@ async fn handle_delete(DeletionReason::AccessRevoked => LinkDisconnectReason::AccessRevoked,},}),- )- .await;+ );// Mark the link as deleted in history table for tracking (best-effort)if let Err(e) = email_db_client::links_history::update::set_deleted_at(diff --git a/services/email_service/src/pubsub/scheduled/process.rs b/services/email_service/src/pubsub/scheduled/process.rsindex 3766444967..c2341c2c46 100644--- a/services/email_service/src/pubsub/scheduled/process.rs+++ b/services/email_service/src/pubsub/scheduled/process.rs@@ -222,8 +222,7 @@ async fn process_scheduled_message_inner(origin: EmailEventOrigin::UserAction,sent_at: Utc::now(),}),- )- .await;+ );}// Cleanup attachments in the background after successful senddiff --git a/services/email_service/src/pubsub/util.rs b/services/email_service/src/pubsub/util.rsindex 04bb6479aa..d13918929f 100644--- a/services/email_service/src/pubsub/util.rs+++ b/services/email_service/src/pubsub/util.rs@@ -128,10 +128,9 @@ pub async fn complete_transaction_with_processing_error<T>(/// Publish an email event to the `macro.email` Kafka topic, logging and/// dropping failures — event emission must never fail the email operation.-pub async fn publish_email_event<B: MacroEventBroker>(broker: &B, event: &EmailMacroEvent) {+pub fn publish_email_event<B: MacroEventBroker>(broker: &B, event: &EmailMacroEvent) {let _ = broker.send_event(event)- .await.inspect_err(|e| tracing::error!(error=?e, "failed to publish email macro event"));}