Skip to content

Commit 36d1592

Browse files
authored
fix: do not output every js_run_devserver watch protocol error (#2287)
1 parent 8a818b7 commit 36d1592

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

js/private/js_run_devserver.mjs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)