File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -772,9 +772,6 @@ class AspectWatchProtocol {
772772
773773 // Propagate connection errors to a configurable callback
774774 this . _error = console . error
775- this . connection . on ( 'error' , ( err ) => {
776- this . _error ( err )
777- } )
778775 }
779776
780777 async connect ( ) {
@@ -843,7 +840,7 @@ class AspectWatchProtocol {
843840 }
844841
845842 async _receive ( type = null ) {
846- return new Promise ( ( resolve , reject ) => {
843+ return await new Promise ( ( resolve , reject ) => {
847844 const dataBufs = [ ]
848845 const connection = this . connection
849846
@@ -877,17 +874,21 @@ class AspectWatchProtocol {
877874 }
878875
879876 async _send ( type , data = { } ) {
880- return new Promise ( ( resolve , reject ) => {
881- this . connection . write (
882- JSON . stringify ( { kind : type , ...data } ) + '\n' ,
883- function ( err ) {
884- if ( err ) {
885- reject ( err )
886- } else {
887- resolve ( )
877+ return await new Promise ( ( resolve , reject ) => {
878+ try {
879+ this . connection . write (
880+ JSON . stringify ( { kind : type , ...data } ) + '\n' ,
881+ function ( err ) {
882+ if ( err ) {
883+ reject ( err )
884+ } else {
885+ resolve ( )
886+ }
888887 }
889- }
890- )
888+ )
889+ } catch ( err ) {
890+ reject ( err )
891+ }
891892 } )
892893 }
893894}
You can’t perform that action at this time.
0 commit comments