File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -841,17 +841,22 @@ class AspectWatchProtocol {
841841
842842 async _receive ( type = null ) {
843843 return new Promise ( ( resolve , reject ) => {
844- let line = ''
845- const dataReceived = ( data ) => {
846- line += data . toString ( )
847- if ( ! line . endsWith ( '\n' ) ) {
844+ const dataBufs = [ ]
845+ const connection = this . connection
846+
847+ connection . on ( 'data' , function dataReceived ( data ) {
848+ dataBufs . push ( data )
849+
850+ if ( data . at ( data . byteLength - 1 ) !== '\n' . charCodeAt ( 0 ) ) {
848851 return
849852 }
850853
851- this . connection . off ( 'data' , dataReceived )
854+ connection . off ( 'data' , dataReceived )
852855
853856 try {
854- const msg = JSON . parse ( line . trim ( ) )
857+ const msg = JSON . parse (
858+ Buffer . concat ( dataBufs ) . toString ( ) . trim ( )
859+ )
855860 if ( type && msg . kind !== type ) {
856861 reject (
857862 new Error (
@@ -864,9 +869,7 @@ class AspectWatchProtocol {
864869 } catch ( e ) {
865870 reject ( e )
866871 }
867- }
868-
869- this . connection . on ( 'data' , dataReceived )
872+ } )
870873 } )
871874 }
872875
You can’t perform that action at this time.
0 commit comments