Auto-indexing service and GraphQL API for AT Protocol Records
0
fork

Configure Feed

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

fix: correct jetstream heartbeat timestamp unit conversion

The FFI call erlang_system_time(1_000_000) was returning microseconds,
not milliseconds as intended. This caused the heartbeat check to compute
incorrect time differences, triggering spurious consumer restarts.

Replaced with gleam/time/timestamp for correct millisecond conversion.

+10 -7
+10 -7
server/src/jetstream_consumer.gleam
··· 11 11 import gleam/option 12 12 import gleam/otp/actor 13 13 import gleam/string 14 + import gleam/time/timestamp 14 15 import goose 15 16 import logging 16 17 import sqlight ··· 428 429 } 429 430 430 431 /// Get current timestamp in seconds (for tracking flush intervals) 431 - @external(erlang, "erlang", "system_time") 432 - fn erlang_system_time(unit: Int) -> Int 433 - 434 432 fn get_current_time_seconds() -> Int { 435 - // Time unit: 1 = seconds 436 - erlang_system_time(1) 433 + let #(seconds, _nanoseconds) = 434 + timestamp.system_time() 435 + |> timestamp.to_unix_seconds_and_nanoseconds 436 + seconds 437 437 } 438 438 439 + /// Get current timestamp in milliseconds 439 440 fn get_current_time_milliseconds() -> Int { 440 - // Time unit: 1000000 = milliseconds 441 - erlang_system_time(1_000_000) 441 + let #(seconds, nanoseconds) = 442 + timestamp.system_time() 443 + |> timestamp.to_unix_seconds_and_nanoseconds 444 + seconds * 1000 + nanoseconds / 1_000_000 442 445 } 443 446 444 447 /// Handle cursor tracker messages