File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ function setupWebSocketProxy (fastify, options) {
8888 oldClose . call ( this , done )
8989 }
9090
91+ server . on ( 'error' , ( err ) => {
92+ fastify . log . error ( err )
93+ } )
94+
9195 server . on ( 'connection' , ( source , request ) => {
9296 const url = createWebSocketUrl ( options , request )
9397
Original file line number Diff line number Diff line change @@ -52,3 +52,18 @@ test('basic websocket proxy', async (t) => {
5252 server . close ( )
5353 ] )
5454} )
55+
56+ test ( 'captures errors on start' , async ( t ) => {
57+ const app = Fastify ( )
58+ await app . listen ( 0 )
59+
60+ const app2 = Fastify ( )
61+ app2 . register ( proxy , { upstream : 'http://localhost' , websocket : true } )
62+
63+ const appPort = app . server . address ( ) . port
64+
65+ await t . rejects ( app2 . listen ( appPort ) , / E A D D R I N U S E / )
66+
67+ t . tearDown ( app . close . bind ( app ) )
68+ t . tearDown ( app2 . close . bind ( app2 ) )
69+ } )
You can’t perform that action at this time.
0 commit comments