@@ -14,6 +14,7 @@ import type {
14
14
ScheduledEvent ,
15
15
AlarmEvent ,
16
16
EmailEvent ,
17
+ TailInfo ,
17
18
} from "../tail/createTail" ;
18
19
import type { RequestInit } from "undici" ;
19
20
import type WebSocket from "ws" ;
@@ -56,10 +57,10 @@ describe("tail", () => {
56
57
await runWrangler ( "tail durable-object--websocket--response" ) ;
57
58
expect ( std . out ) . toMatchInlineSnapshot ( `""` ) ;
58
59
expect ( std . warn ) . toMatchInlineSnapshot ( `
59
- "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mBeginning log collection requires restarting the Durable Objects associated with durable-object--websocket--response. Any WebSocket connections or other non-persisted state will be lost as part of this restart.[0m
60
+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mBeginning log collection requires restarting the Durable Objects associated with durable-object--websocket--response. Any WebSocket connections or other non-persisted state will be lost as part of this restart.[0m
60
61
61
- "
62
- ` ) ;
62
+ "
63
+ `) ;
63
64
expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
64
65
} ) ;
65
66
it ( "creates and then delete tails" , async ( ) => {
@@ -503,10 +504,31 @@ describe("tail", () => {
503
504
)
504
505
. replace ( mockTailExpiration . toISOString ( ) , "[mock expiration date]" )
505
506
) . toMatchInlineSnapshot ( `
506
- "Successfully created tail, expires at [mock expiration date]
507
- Connected to test-worker, waiting for logs...
508
- Email from:${ mockEmailEventFrom } to:${ mockEmailEventTo } size:${ mockEmailEventSize } @ [mock event timestamp] - Ok"
509
- ` ) ;
507
+ "Successfully created tail, expires at [mock expiration date]
508
+ Connected to test-worker, waiting for logs...
509
+ Email from:[email protected] to:[email protected] size:45416 @ [mock event timestamp] - Ok"
510
+ ` ) ;
511
+ } ) ;
512
+
513
+ it ( "logs tail overload message" , async ( ) => {
514
+ const api = mockWebsocketAPIs ( ) ;
515
+ await runWrangler ( "tail test-worker --format pretty" ) ;
516
+
517
+ const event = generateTailInfo ( ) ;
518
+ const message = generateMockEventMessage ( { event } ) ;
519
+ const serializedMessage = serialize ( message ) ;
520
+
521
+ api . ws . send ( serializedMessage ) ;
522
+ expect (
523
+ std . out . replace (
524
+ mockTailExpiration . toISOString ( ) ,
525
+ "[mock expiration date]"
526
+ )
527
+ ) . toMatchInlineSnapshot ( `
528
+ "Successfully created tail, expires at [mock expiration date]
529
+ Connected to test-worker, waiting for logs...
530
+ Tail is currently in sampling mode due to the high volume of messages. To prevent messages from being dropped consider adding filters."
531
+ ` ) ;
510
532
} ) ;
511
533
512
534
it ( "should not crash when the tail message has a void event" , async ( ) => {
@@ -675,6 +697,7 @@ function isRequest(
675
697
| RequestEvent
676
698
| AlarmEvent
677
699
| EmailEvent
700
+ | TailInfo
678
701
| undefined
679
702
| null
680
703
) : event is RequestEvent {
@@ -956,3 +979,11 @@ function generateMockEmailEvent(opts?: Partial<EmailEvent>): EmailEvent {
956
979
rawSize : opts ?. rawSize || mockEmailEventSize ,
957
980
} ;
958
981
}
982
+
983
+ function generateTailInfo ( ) : TailInfo {
984
+ return {
985
+ message :
986
+ "Tail is currently in sampling mode due to the high volume of messages. To prevent messages from being dropped consider adding filters." ,
987
+ type : "overload" ,
988
+ } ;
989
+ }
0 commit comments