@@ -207,108 +207,6 @@ describe('ServerRuntimeClient', () => {
207207 } ) ;
208208 } ) ;
209209
210- describe ( 'log weight-based flushing' , ( ) => {
211- it ( 'flushes logs when weight exceeds 800KB' , ( ) => {
212- const options = getDefaultClientOptions ( {
213- dsn : PUBLIC_DSN ,
214- enableLogs : true ,
215- } ) ;
216- client = new ServerRuntimeClient ( options ) ;
217- const scope = new Scope ( ) ;
218- scope . setClient ( client ) ;
219-
220- const sendEnvelopeSpy = vi . spyOn ( client , 'sendEnvelope' ) ;
221-
222- // Create a large log message that will exceed the 800KB threshold
223- const largeMessage = 'x' . repeat ( 400_000 ) ; // 400KB string
224- _INTERNAL_captureLog ( { message : largeMessage , level : 'info' } , scope ) ;
225-
226- expect ( sendEnvelopeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
227- expect ( client [ '_logWeight' ] ) . toBe ( 0 ) ; // Weight should be reset after flush
228- } ) ;
229-
230- it ( 'accumulates log weight without flushing when under threshold' , ( ) => {
231- const options = getDefaultClientOptions ( {
232- dsn : PUBLIC_DSN ,
233- enableLogs : true ,
234- } ) ;
235- client = new ServerRuntimeClient ( options ) ;
236- const scope = new Scope ( ) ;
237- scope . setClient ( client ) ;
238-
239- const sendEnvelopeSpy = vi . spyOn ( client , 'sendEnvelope' ) ;
240-
241- // Create a log message that won't exceed the threshold
242- const message = 'x' . repeat ( 100_000 ) ; // 100KB string
243- _INTERNAL_captureLog ( { message, level : 'info' } , scope ) ;
244-
245- expect ( sendEnvelopeSpy ) . not . toHaveBeenCalled ( ) ;
246- expect ( client [ '_logWeight' ] ) . toBeGreaterThan ( 0 ) ;
247- } ) ;
248-
249- it ( 'flushes logs on flush event' , ( ) => {
250- const options = getDefaultClientOptions ( {
251- dsn : PUBLIC_DSN ,
252- enableLogs : true ,
253- } ) ;
254- client = new ServerRuntimeClient ( options ) ;
255- const scope = new Scope ( ) ;
256- scope . setClient ( client ) ;
257-
258- const sendEnvelopeSpy = vi . spyOn ( client , 'sendEnvelope' ) ;
259-
260- // Add some logs
261- _INTERNAL_captureLog ( { message : 'test1' , level : 'info' } , scope ) ;
262- _INTERNAL_captureLog ( { message : 'test2' , level : 'info' } , scope ) ;
263-
264- // Trigger flush directly
265- _INTERNAL_flushLogsBuffer ( client ) ;
266-
267- expect ( sendEnvelopeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
268- expect ( client [ '_logWeight' ] ) . toBe ( 0 ) ; // Weight should be reset after flush
269- } ) ;
270-
271- it ( 'does not flush logs when logs are disabled' , ( ) => {
272- const options = getDefaultClientOptions ( {
273- dsn : PUBLIC_DSN ,
274- } ) ;
275- client = new ServerRuntimeClient ( options ) ;
276- const scope = new Scope ( ) ;
277- scope . setClient ( client ) ;
278-
279- const sendEnvelopeSpy = vi . spyOn ( client , 'sendEnvelope' ) ;
280-
281- // Create a large log message
282- const largeMessage = 'x' . repeat ( 400_000 ) ;
283- _INTERNAL_captureLog ( { message : largeMessage , level : 'info' } , scope ) ;
284-
285- expect ( sendEnvelopeSpy ) . not . toHaveBeenCalled ( ) ;
286- expect ( client [ '_logWeight' ] ) . toBe ( 0 ) ;
287- } ) ;
288-
289- it ( 'flushes logs when flush event is triggered' , ( ) => {
290- const options = getDefaultClientOptions ( {
291- dsn : PUBLIC_DSN ,
292- enableLogs : true ,
293- } ) ;
294- client = new ServerRuntimeClient ( options ) ;
295- const scope = new Scope ( ) ;
296- scope . setClient ( client ) ;
297-
298- const sendEnvelopeSpy = vi . spyOn ( client , 'sendEnvelope' ) ;
299-
300- // Add some logs
301- _INTERNAL_captureLog ( { message : 'test1' , level : 'info' } , scope ) ;
302- _INTERNAL_captureLog ( { message : 'test2' , level : 'info' } , scope ) ;
303-
304- // Trigger flush event
305- client . emit ( 'flush' ) ;
306-
307- expect ( sendEnvelopeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
308- expect ( client [ '_logWeight' ] ) . toBe ( 0 ) ; // Weight should be reset after flush
309- } ) ;
310- } ) ;
311-
312210 describe ( 'user-agent header' , ( ) => {
313211 it ( 'sends user-agent header with SDK name and version' , ( ) => {
314212 const options = getDefaultClientOptions ( { dsn : PUBLIC_DSN } ) ;
0 commit comments