File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -156,13 +156,22 @@ class IOpipeWrapperClass {
156
156
this . context ,
157
157
this . callback
158
158
) ;
159
- if ( result && result . then && result . catch ) {
160
- return new Promise ( ( ) => this . callback ( null , ( ) => result ) )
161
- . then ( value => value )
162
- . catch ( err => {
163
- this . sendReport ( err , ( ) => this . originalCallback ( err ) ) ;
164
- return err ;
165
- } ) ;
159
+ if (
160
+ result &&
161
+ typeof result . then === 'function' &&
162
+ typeof result . catch === 'function'
163
+ ) {
164
+ return new Promise ( resolve => {
165
+ return result
166
+ . then ( value => {
167
+ this . context . succeed ( value ) ;
168
+ return this . callback ( null , ( ) => resolve ( value ) ) ;
169
+ } )
170
+ . catch ( err => {
171
+ this . context . fail ( err ) ;
172
+ return this . callback ( err ) ;
173
+ } ) ;
174
+ } ) ;
166
175
}
167
176
return result ;
168
177
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments