@@ -8,13 +8,15 @@ import * as PathRewriter from './path-rewriter';
8
8
import * as Router from './router' ;
9
9
import { Debug as debug } from './debug' ;
10
10
import { getFunctionName } from './utils/function' ;
11
+ import { getLogger } from './logger' ;
11
12
12
13
export class HttpProxyMiddleware {
13
14
private wsInternalSubscribed = false ;
14
15
private serverOnCloseSubscribed = false ;
15
16
private proxyOptions : Options ;
16
17
private proxy : httpProxy ;
17
18
private pathRewriter ;
19
+ private logger = getLogger ( { logger : console } ) ;
18
20
19
21
constructor ( options : Options ) {
20
22
verifyConfig ( options ) ;
@@ -95,7 +97,10 @@ export class HttpProxyMiddleware {
95
97
private handleUpgrade = async ( req : Request , socket , head ) => {
96
98
if ( this . shouldProxy ( this . proxyOptions . pathFilter , req ) ) {
97
99
const activeProxyOptions = await this . prepareProxyRequest ( req ) ;
98
- this . proxy . ws ( req , socket , head , activeProxyOptions ) ;
100
+ this . proxy . ws ( req , socket , head , activeProxyOptions , ( err , req , socket ) => {
101
+ this . logger . error ( '[HPM] Upgrading to WebSocket Error:' , err , req , socket ) ;
102
+ } ) ;
103
+
99
104
debug ( 'server upgrade event received. Proxying WebSocket' ) ;
100
105
}
101
106
} ;
0 commit comments