File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/react-on-rails-pro-node-renderer/tests Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ const makeRequest = async (options = {}) => {
3434 const jsonChunks = [ ] ;
3535 let firstByteTime ;
3636 let status ;
37+ let buffer = '' ;
3738 const decoder = new TextDecoder ( ) ;
3839
3940 request . on ( 'response' , ( headers ) => {
@@ -44,10 +45,17 @@ const makeRequest = async (options = {}) => {
4445 // Sometimes, multiple chunks are merged into one.
4546 // So, the server uses \n as a delimiter between chunks.
4647 const decodedData = typeof data === 'string' ? data : decoder . decode ( data , { stream : false } ) ;
47- const decodedChunksFromData = decodedData
48+ const decodedChunksFromData = ( buffer + decodedData )
4849 . split ( '\n' )
4950 . map ( ( chunk ) => chunk . trim ( ) )
5051 . filter ( ( chunk ) => chunk . length > 0 ) ;
52+
53+ if ( ! decodedData . endsWith ( '\n' ) ) {
54+ buffer = decodedChunksFromData . pop ( ) ?? '' ;
55+ } else {
56+ buffer = '' ;
57+ }
58+
5159 chunks . push ( ...decodedChunksFromData ) ;
5260 jsonChunks . push (
5361 ...decodedChunksFromData . map ( ( chunk ) => {
You can’t perform that action at this time.
0 commit comments