@@ -276,7 +276,7 @@ export class JetStreamClientImpl extends BaseApiClient
276
276
if ( err ) {
277
277
throw err ;
278
278
}
279
- return toJsMsg ( msg ) ;
279
+ return toJsMsg ( msg , this . timeout ) ;
280
280
}
281
281
282
282
/*
@@ -389,7 +389,7 @@ export class JetStreamClientImpl extends BaseApiClient
389
389
// if we are doing heartbeats, message resets
390
390
monitor ?. work ( ) ;
391
391
qi . received ++ ;
392
- qi . push ( toJsMsg ( msg ) ) ;
392
+ qi . push ( toJsMsg ( msg , this . timeout ) ) ;
393
393
}
394
394
} ,
395
395
} ) ;
@@ -653,7 +653,7 @@ export class JetStreamClientImpl extends BaseApiClient
653
653
jsi : JetStreamSubscriptionInfo ,
654
654
) : TypedSubscriptionOptions < JsMsg > {
655
655
const so = { } as TypedSubscriptionOptions < JsMsg > ;
656
- so . adapter = msgAdapter ( jsi . callbackFn === undefined ) ;
656
+ so . adapter = msgAdapter ( jsi . callbackFn === undefined , this . timeout ) ;
657
657
so . ingestionFilterFn = JetStreamClientImpl . ingestionFn ( jsi . ordered ) ;
658
658
so . protocolFilterFn = ( jm , ingest = false ) : boolean => {
659
659
const jsmi = jm as JsMsgImpl ;
@@ -979,44 +979,50 @@ class JetStreamPullSubscriptionImpl extends JetStreamSubscriptionImpl
979
979
}
980
980
}
981
981
982
- function msgAdapter ( iterator : boolean ) : MsgAdapter < JsMsg > {
982
+ function msgAdapter ( iterator : boolean , ackTimeout : number ) : MsgAdapter < JsMsg > {
983
983
if ( iterator ) {
984
- return iterMsgAdapter ;
984
+ return iterMsgAdapter ( ackTimeout ) ;
985
985
} else {
986
- return cbMsgAdapter ;
986
+ return cbMsgAdapter ( ackTimeout ) ;
987
987
}
988
988
}
989
989
990
- function cbMsgAdapter (
991
- err : NatsError | null ,
992
- msg : Msg ,
993
- ) : [ NatsError | null , JsMsg | null ] {
994
- if ( err ) {
995
- return [ err , null ] ;
996
- }
997
- err = checkJsError ( msg ) ;
998
- if ( err ) {
999
- return [ err , null ] ;
1000
- }
1001
- // assuming that the protocolFilterFn is set!
1002
- return [ null , toJsMsg ( msg ) ] ;
990
+ function cbMsgAdapter ( ackTimeout : number ) : MsgAdapter < JsMsg > {
991
+ return (
992
+ err : NatsError | null ,
993
+ msg : Msg ,
994
+ ) : [ NatsError | null , JsMsg | null ] => {
995
+ if ( err ) {
996
+ return [ err , null ] ;
997
+ }
998
+ err = checkJsError ( msg ) ;
999
+ if ( err ) {
1000
+ return [ err , null ] ;
1001
+ }
1002
+ // assuming that the protocolFilterFn is set!
1003
+ return [ null , toJsMsg ( msg , ackTimeout ) ] ;
1004
+ } ;
1003
1005
}
1004
1006
1005
1007
function iterMsgAdapter (
1006
- err : NatsError | null ,
1007
- msg : Msg ,
1008
- ) : [ NatsError | null , JsMsg | null ] {
1009
- if ( err ) {
1010
- return [ err , null ] ;
1011
- }
1012
- // iterator will close if we have an error
1013
- // check for errors that shouldn't close it
1014
- const ne = checkJsError ( msg ) ;
1015
- if ( ne !== null ) {
1016
- return [ hideNonTerminalJsErrors ( ne ) , null ] ;
1017
- }
1018
- // assuming that the protocolFilterFn is set
1019
- return [ null , toJsMsg ( msg ) ] ;
1008
+ ackTimeout : number ,
1009
+ ) : MsgAdapter < JsMsg > {
1010
+ return (
1011
+ err : NatsError | null ,
1012
+ msg : Msg ,
1013
+ ) : [ NatsError | null , JsMsg | null ] => {
1014
+ if ( err ) {
1015
+ return [ err , null ] ;
1016
+ }
1017
+ // iterator will close if we have an error
1018
+ // check for errors that shouldn't close it
1019
+ const ne = checkJsError ( msg ) ;
1020
+ if ( ne !== null ) {
1021
+ return [ hideNonTerminalJsErrors ( ne ) , null ] ;
1022
+ }
1023
+ // assuming that the protocolFilterFn is set
1024
+ return [ null , toJsMsg ( msg , ackTimeout ) ] ;
1025
+ } ;
1020
1026
}
1021
1027
1022
1028
function hideNonTerminalJsErrors ( ne : NatsError ) : NatsError | null {
0 commit comments