File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/implementation/Client/GRPCClient Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -127,16 +127,30 @@ export default class GRPCClientConfiguration implements IClientConfiguration {
127127 await cb ( wrapped ) ;
128128 } ) ;
129129
130+ // Add error handler to prevent unhandled errors
131+ stream . on ( "error" , ( err ) => {
132+ // Log the error but don't throw - this prevents process crashes
133+ console . warn ( "Configuration subscription stream error:" , err ) ;
134+ } ) ;
135+
130136 return {
131137 stop : async ( ) => {
132- return new Promise ( ( resolve , reject ) => {
138+ return new Promise ( ( resolve ) => {
139+ // If no streamId, just clean up the stream without unsubscribing
140+ if ( ! streamId ) {
141+ stream . removeAllListeners ( ) ;
142+ stream . destroy ( ) ;
143+ return resolve ( ) ;
144+ }
145+
133146 const req = new UnsubscribeConfigurationRequest ( ) ;
134147 req . setStoreName ( storeName ) ;
135148 req . setId ( streamId ) ;
136149
137150 client . unsubscribeConfiguration ( req , ( err , res : UnsubscribeConfigurationResponse ) => {
138151 if ( err || ! res . getOk ( ) ) {
139- return reject ( res . getMessage ( ) ) ;
152+ // Don't reject, just log and clean up
153+ console . warn ( "Failed to unsubscribe configuration:" , err || res . getMessage ( ) ) ;
140154 }
141155
142156 // Clean up the node.js event emitter
You can’t perform that action at this time.
0 commit comments