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 {
772
772
773
773
// Propagate connection errors to a configurable callback
774
774
this . _error = console . error
775
- this . connection . on ( 'error' , ( err ) => {
776
- this . _error ( err )
777
- } )
778
775
}
779
776
780
777
async connect ( ) {
@@ -843,7 +840,7 @@ class AspectWatchProtocol {
843
840
}
844
841
845
842
async _receive ( type = null ) {
846
- return new Promise ( ( resolve , reject ) => {
843
+ return await new Promise ( ( resolve , reject ) => {
847
844
const dataBufs = [ ]
848
845
const connection = this . connection
849
846
@@ -877,17 +874,21 @@ class AspectWatchProtocol {
877
874
}
878
875
879
876
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
+ }
888
887
}
889
- }
890
- )
888
+ )
889
+ } catch ( err ) {
890
+ reject ( err )
891
+ }
891
892
} )
892
893
}
893
894
}
You can’t perform that action at this time.
0 commit comments