@@ -1506,13 +1506,6 @@ class Http2Stream extends Duplex {
15061506 this . once ( 'ready' , this . _destroy . bind ( this , err , callback ) ) ;
15071507 return ;
15081508 }
1509-
1510- const server = session [ kServer ] ;
1511-
1512- if ( err && server ) {
1513- server . emit ( 'streamError' , err , this ) ;
1514- }
1515-
15161509 process . nextTick ( ( ) => {
15171510 debug ( `[${ sessionName ( session [ kType ] ) } ] destroying stream ${ this [ kID ] } ` ) ;
15181511
@@ -1536,8 +1529,9 @@ class Http2Stream extends Duplex {
15361529 // All done
15371530 const rst = this [ kState ] . rst ;
15381531 const code = rst ? this [ kState ] . rstCode : NGHTTP2_NO_ERROR ;
1539- if ( ! err && code !== NGHTTP2_NO_ERROR ) {
1540- err = new errors . Error ( 'ERR_HTTP2_STREAM_ERROR' , code ) ;
1532+ if ( code !== NGHTTP2_NO_ERROR ) {
1533+ const err = new errors . Error ( 'ERR_HTTP2_STREAM_ERROR' , code ) ;
1534+ process . nextTick ( ( ) => this . emit ( 'error' , err ) ) ;
15411535 }
15421536 process . nextTick ( emit . bind ( this , 'streamClosed' , code ) ) ;
15431537 debug ( `[${ sessionName ( session [ kType ] ) } ] stream ${ this [ kID ] } destroyed` ) ;
@@ -1640,24 +1634,13 @@ function doSendFileFD(session, options, fd, headers, getTrailers, err, stat) {
16401634 abort ( this ) ;
16411635 return ;
16421636 }
1643- const onError = options . onError ;
1644-
16451637 if ( err ) {
1646- if ( onError ) {
1647- onError ( err ) ;
1648- } else {
1649- this . destroy ( err ) ;
1650- }
1638+ process . nextTick ( ( ) => this . emit ( 'error' , err ) ) ;
16511639 return ;
16521640 }
1653-
16541641 if ( ! stat . isFile ( ) ) {
16551642 err = new errors . Error ( 'ERR_HTTP2_SEND_FILE' ) ;
1656- if ( onError ) {
1657- onError ( err ) ;
1658- } else {
1659- this . destroy ( err ) ;
1660- }
1643+ process . nextTick ( ( ) => this . emit ( 'error' , err ) ) ;
16611644 return ;
16621645 }
16631646
@@ -1694,17 +1677,12 @@ function doSendFileFD(session, options, fd, headers, getTrailers, err, stat) {
16941677
16951678function afterOpen ( session , options , headers , getTrailers , err , fd ) {
16961679 const state = this [ kState ] ;
1697- const onError = options . onError ;
16981680 if ( this . destroyed || session . destroyed ) {
16991681 abort ( this ) ;
17001682 return ;
17011683 }
17021684 if ( err ) {
1703- if ( onError ) {
1704- onError ( err ) ;
1705- } else {
1706- this . destroy ( err ) ;
1707- }
1685+ process . nextTick ( ( ) => this . emit ( 'error' , err ) ) ;
17081686 return ;
17091687 }
17101688 state . fd = fd ;
@@ -1713,20 +1691,13 @@ function afterOpen(session, options, headers, getTrailers, err, fd) {
17131691 doSendFileFD . bind ( this , session , options , fd , headers , getTrailers ) ) ;
17141692}
17151693
1716- function streamOnError ( err ) {
1717- // we swallow the error for parity with HTTP1
1718- // all the errors that ends here are not critical for the project
1719- debug ( 'ServerHttp2Stream errored, avoiding uncaughtException' , err ) ;
1720- }
1721-
17221694
17231695class ServerHttp2Stream extends Http2Stream {
17241696 constructor ( session , id , options , headers ) {
17251697 super ( session , options ) ;
17261698 this [ kInit ] ( id ) ;
17271699 this [ kProtocol ] = headers [ HTTP2_HEADER_SCHEME ] ;
17281700 this [ kAuthority ] = headers [ HTTP2_HEADER_AUTHORITY ] ;
1729- this . on ( 'error' , streamOnError ) ;
17301701 debug ( `[${ sessionName ( session [ kType ] ) } ] created serverhttp2stream` ) ;
17311702 }
17321703
@@ -2585,8 +2556,6 @@ module.exports = {
25852556 createServer,
25862557 createSecureServer,
25872558 connect,
2588- Http2Session,
2589- Http2Stream,
25902559 Http2ServerRequest,
25912560 Http2ServerResponse
25922561} ;
0 commit comments