@@ -110,6 +110,37 @@ nodeOnly(() => {
110
110
expect ( fourthDataEvent . eventTimestamp ) . to . be . greaterThan ( thirdDataEvent . eventTimestamp ) ;
111
111
} ) ;
112
112
113
+ it ( "should expose large received data" , async ( ) => {
114
+ const openDeferred = getDeferred < RawPassthroughEvent > ( ) ;
115
+ let receivedDataEvents = [ ] as RawPassthroughDataEvent [ ] ;
116
+
117
+ await server . on ( 'raw-passthrough-opened' , ( e ) => openDeferred . resolve ( e ) ) ;
118
+ await server . on ( 'raw-passthrough-data' , ( e ) => {
119
+ if ( e . direction === 'received' ) {
120
+ receivedDataEvents . push ( e )
121
+ }
122
+ } ) ;
123
+
124
+ const socksSocket = await openSocksSocket ( server , 'localhost' , remotePort ) ;
125
+
126
+ const message = 'hello' . repeat ( 20_000 ) ; // =100KB each
127
+
128
+ // Write 500KB in 100KB chunks with a brief delay. Larger than one TCP packet (65K)
129
+ // in all cases, should cause some weirdness.
130
+ for ( let i = 0 ; i < 5 ; i ++ ) {
131
+ socksSocket . write ( message ) ;
132
+ await delay ( 0 ) ;
133
+ }
134
+
135
+ await openDeferred ;
136
+ await delay ( 10 ) ;
137
+
138
+ const totalLength = receivedDataEvents . reduce ( ( sum , e ) => sum + e . content . toString ( ) . length , 0 ) ;
139
+ expect ( totalLength ) . to . equal ( 500_000 ) ;
140
+ expect ( receivedDataEvents [ 0 ] . content . slice ( 0 , 5 ) . toString ( ) ) . to . equal ( 'hello' ) ;
141
+ expect ( receivedDataEvents [ receivedDataEvents . length - 1 ] . content . slice ( - 5 ) . toString ( ) ) . to . equal ( 'hello' ) ;
142
+ } ) ;
143
+
113
144
describe ( "with a remote client" , ( ) => {
114
145
const adminServer = getAdminServer ( ) ;
115
146
const remoteClient = getRemote ( {
0 commit comments