File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -472,6 +472,19 @@ describe("monitorTelegramProvider (grammY)", () => {
472472 expect ( runOptions ?. runner ?. retryInterval ) . toBe ( "exponential" ) ;
473473 } ) ;
474474
475+ it ( "logs polling startup diagnostics without using the error channel" , async ( ) => {
476+ const runtime = {
477+ log : vi . fn ( ) ,
478+ error : vi . fn ( ) ,
479+ exit : vi . fn ( ) ,
480+ } ;
481+
482+ await monitorWithAutoAbort ( { runtime } ) ;
483+
484+ expect ( runtime . log ) . toHaveBeenCalledWith ( expect . stringContaining ( "polling cycle started" ) ) ;
485+ expect ( runtime . error ) . not . toHaveBeenCalled ( ) ;
486+ } ) ;
487+
475488 it ( "requires mention in groups by default" , async ( ) => {
476489 for ( const v of Object . values ( api ) ) {
477490 if ( typeof v === "function" && "mockReset" in v ) {
Original file line number Diff line number Diff line change @@ -108,7 +108,8 @@ async function loadTelegramMonitorWebhookRuntime() {
108108}
109109
110110export async function monitorTelegramProvider ( opts : MonitorTelegramOpts = { } ) {
111- const log = opts . runtime ?. error ?? console . error ;
111+ const log = ( line : string ) => ( opts . runtime ?. log ?? console . log ) ( line ) ;
112+ const logError = ( line : string ) => ( opts . runtime ?. error ?? console . error ) ( line ) ;
112113 let pollingSession : TelegramPollingSessionInstance | undefined ;
113114
114115 const handlePollingNetworkFailure = ( err : unknown , label : string ) => {
@@ -231,7 +232,7 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
231232 try {
232233 await deleteTelegramUpdateOffset ( { accountId : account . accountId } ) ;
233234 } catch ( err ) {
234- ( opts . runtime ?. error ?? console . error ) (
235+ logError (
235236 `telegram: failed to delete stale update offset after rotation: ${ String ( err ) } ` ,
236237 ) ;
237238 }
@@ -261,9 +262,7 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
261262 botToken : token ,
262263 } ) ;
263264 } catch ( err ) {
264- ( opts . runtime ?. error ?? console . error ) (
265- `telegram: failed to persist update offset: ${ String ( err ) } ` ,
266- ) ;
265+ logError ( `telegram: failed to persist update offset: ${ String ( err ) } ` ) ;
267266 }
268267 } ;
269268
You can’t perform that action at this time.
0 commit comments