@@ -4264,8 +4264,12 @@ describe("PiAdapterV2", () => {
42644264} ) ;
42654265
42664266describe ( "PiRpc framing" , ( ) => {
4267- it . effect ( "reassembles records across chunk boundaries and strips CR" , ( ) =>
4268- Effect . gen ( function * ( ) {
4267+ it . effect ( "reassembles records and warns when dropping oversized records" , ( ) => {
4268+ const warnings : Array < ReadonlyArray < unknown > > = [ ] ;
4269+ const logCapture = Logger . make < unknown , void > ( ( { logLevel, message } ) => {
4270+ if ( logLevel === "Warn" && Array . isArray ( message ) ) warnings . push ( message ) ;
4271+ } ) ;
4272+ return Effect . gen ( function * ( ) {
42694273 const stdout = yield * Queue . unbounded < Uint8Array > ( ) ;
42704274 const spawner = ChildProcessSpawner . make ( ( ) =>
42714275 Effect . succeed (
@@ -4296,7 +4300,8 @@ describe("PiRpc framing", () => {
42964300 yield * push ( '{"type":"agent_' ) ;
42974301 yield * push ( 'start"}\r\n{"type":"agent_settled"}\nnot json\n{"type":"queue_update"}\n' ) ;
42984302
4299- yield * push ( '{"type":"must_not_emit","text":"' ) ;
4303+ const head = '{"type":"must_not_emit","text":"' ;
4304+ yield * push ( head ) ;
43004305 const chunk = new TextEncoder ( ) . encode ( "x" . repeat ( 8 * 1024 * 1024 ) ) ;
43014306 for ( let index = 0 ; index < 32 ; index ++ ) yield * Queue . offer ( stdout , chunk ) ;
43024307 yield * push ( '"}\n{"type":"after_oversized"}\n' ) ;
@@ -4308,48 +4313,6 @@ describe("PiRpc framing", () => {
43084313 const third = yield * Queue . take ( connection . events ) ;
43094314 assert . equal ( third [ "type" ] , "queue_update" ) ;
43104315 assert . equal ( ( yield * Queue . take ( connection . events ) ) [ "type" ] , "after_oversized" ) ;
4311- } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
4312- ) ;
4313-
4314- it . effect ( "logs the length of an oversized record it drops" , ( ) => {
4315- const warnings : Array < ReadonlyArray < unknown > > = [ ] ;
4316- const logCapture = Logger . make < unknown , void > ( ( { logLevel, message } ) => {
4317- if ( logLevel === "Warn" && Array . isArray ( message ) ) warnings . push ( message ) ;
4318- } ) ;
4319- return Effect . gen ( function * ( ) {
4320- const stdout = yield * Queue . unbounded < Uint8Array > ( ) ;
4321- const spawner = ChildProcessSpawner . make ( ( ) =>
4322- Effect . succeed (
4323- ChildProcessSpawner . makeHandle ( {
4324- pid : ChildProcessSpawner . ProcessId ( FAKE_PID ) ,
4325- exitCode : Effect . never ,
4326- isRunning : Effect . succeed ( true ) ,
4327- kill : ( ) => Effect . void ,
4328- unref : Effect . succeed ( Effect . void ) ,
4329- stdin : Sink . drain ,
4330- stdout : Stream . fromQueue ( stdout ) ,
4331- stderr : Stream . empty ,
4332- all : Stream . empty ,
4333- getInputFd : ( ) => Sink . drain ,
4334- getOutputFd : ( ) => Stream . empty ,
4335- } ) ,
4336- ) ,
4337- ) ;
4338- const connection = yield * makePiRpcConnection ( {
4339- command : "pi" ,
4340- args : [ "--mode" , "rpc" ] ,
4341- cwd : undefined ,
4342- env : { } ,
4343- } ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , spawner ) ) ;
4344-
4345- const head = '{"type":"response","id":"t3-0","success":true,"data":"' ;
4346- const tail = '"}\n{"type":"after_oversized"}\n' ;
4347- const chunk = new TextEncoder ( ) . encode ( "x" . repeat ( 8 * 1024 * 1024 ) ) ;
4348- yield * Queue . offer ( stdout , new TextEncoder ( ) . encode ( head ) ) ;
4349- for ( let index = 0 ; index < 32 ; index ++ ) yield * Queue . offer ( stdout , chunk ) ;
4350- yield * Queue . offer ( stdout , new TextEncoder ( ) . encode ( tail ) ) ;
4351-
4352- assert . equal ( ( yield * Queue . take ( connection . events ) ) [ "type" ] , "after_oversized" ) ;
43534316 assert . lengthOf ( warnings , 1 ) ;
43544317 const [ text , annotations ] = warnings [ 0 ] ?? [ ] ;
43554318 assert . equal ( text , "Dropping oversized pi stdout record." ) ;
0 commit comments