Skip to content

Commit 170cf3d

Browse files
author
jin
committed
$mol_rest_server: no fail on connecion abort
1 parent 9fefe6d commit 170cf3d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

rest/message/http/http.node.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace $ {
1010

1111
@ $mol_mem
1212
uri() {
13-
const addr = this.input.socket?.localAddress ?? 'localhost'
13+
const addr = this.input.socket?.localAddress ?? '::1'
1414
const port = this.input.socket?.localPort ?? '80'
1515
return new URL( this.input.url!, `http://[${addr}]:${port}/` )
1616
}

rest/server/server.node.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace $ {
113113
return
114114
}
115115

116-
socket.on( 'end', $mol_wire_async( ()=> {
116+
const onclose = $mol_wire_async( ()=> {
117117

118118
$mol_wire_sync( this.$ ).$mol_log3_done({
119119
place: this,
@@ -141,7 +141,10 @@ namespace $ {
141141
return
142142
}
143143

144-
} ) )
144+
} )
145+
146+
socket.on( 'end', onclose )
147+
socket.on( 'error', onclose )
145148

146149
socket.on( 'data', ( chunk: Buffer )=> this.ws_income( chunk, upgrade, socket ) )
147150

0 commit comments

Comments
 (0)