This repository was archived by the owner on Mar 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +39
-7
lines changed
Expand file tree Collapse file tree 3 files changed +39
-7
lines changed Original file line number Diff line number Diff line change 11# UNRELEASED
22- [ NEW] Added option for client to authenticate with IAM token server.
3+ - [ FIXED] Case where ` .resume() ` was called on an undefined response.
34
45# 3.0.2 (2019-01-07)
56- [ FIXED] Remove unnecessary ` @types/nano ` dependancy.
Original file line number Diff line number Diff line change @@ -108,14 +108,16 @@ var processState = function(r, callback) {
108108 return ;
109109 }
110110
111- // pass response events/data to awaiting client
112- if ( r . eventRelay ) {
113- r . eventRelay . resume ( ) ;
114- }
115- if ( r . clientStream . destinations . length > 0 ) {
116- r . response . pipe ( r . clientStream . passThroughReadable ) ;
111+ if ( r . response ) {
112+ // pass response events/data to awaiting client
113+ if ( r . eventRelay ) {
114+ r . eventRelay . resume ( ) ;
115+ }
116+ if ( r . clientStream . destinations . length > 0 ) {
117+ r . response . pipe ( r . clientStream . passThroughReadable ) ;
118+ }
119+ r . response . resume ( ) ;
117120 }
118- r . response . resume ( ) ;
119121
120122 // [5] => Return response to awaiting client.
121123 callback ( new Error ( 'No retry requested' ) ) ; // no retry
Original file line number Diff line number Diff line change @@ -201,6 +201,35 @@ describe('CloudantClient', function() {
201201 } ) ;
202202 } ) ;
203203
204+ describe ( 'Error Handling' , function ( ) {
205+ it ( 'Propagate request error: Invalid protocol.' , function ( done ) {
206+ var cloudantClient = new Client ( ) ;
207+ cloudantClient . request ( 'abc://localhost:5984' , function ( err ) {
208+ assert . equal ( err . message , 'Invalid protocol: abc:' ) ;
209+ done ( ) ;
210+ } ) ;
211+ } ) ;
212+
213+ it ( 'Propagate request error: Base URL must be type string.' , function ( done ) {
214+ var cloudantClient = new Client ( ) ;
215+ cloudantClient . request ( { baseUrl : 123 , url : '/_all_dbs' } , function ( err ) {
216+ assert . equal ( err . message , 'options.baseUrl must be a string' ) ;
217+ done ( ) ;
218+ } ) ;
219+ } ) ;
220+
221+ it ( 'Propagate request error: `unix://` URL scheme is no longer supported.' , function ( done ) {
222+ var cloudantClient = new Client ( ) ;
223+ cloudantClient . request ( 'unix://abc' , function ( err ) {
224+ assert . equal (
225+ err . message ,
226+ '`unix://` URL scheme is no longer supported. Please use the format `http://unix:SOCKET:PATH`'
227+ ) ;
228+ done ( ) ;
229+ } ) ;
230+ } ) ;
231+ } ) ;
232+
204233 describe ( 'aborts request' , function ( ) {
205234 it ( 'during plugin execution phase' , function ( done ) {
206235 if ( process . env . NOCK_OFF ) {
You can’t perform that action at this time.
0 commit comments