@@ -3,7 +3,7 @@ import { EventType } from './internalTypes'
33import { safeValue } from './Devtools'
44import { IContext , IConfiguration } from './types'
55
6- export function startDebugOperator ( type , arg , context ) {
6+ export function operatorStarted ( type , arg , context ) {
77 if ( IS_PRODUCTION ) {
88 return
99 }
@@ -17,7 +17,7 @@ export function startDebugOperator(type, arg, context) {
1717 } )
1818}
1919
20- export function stopDebugOperator (
20+ export function operatorStopped (
2121 context ,
2222 value ,
2323 details : {
@@ -27,6 +27,12 @@ export function stopDebugOperator(
2727 } = { }
2828) {
2929 if ( IS_PRODUCTION ) {
30+ if ( value instanceof Promise ) {
31+ context . execution . emit ( EventType . OPERATOR_ASYNC , {
32+ ...context . execution ,
33+ isAsync : true ,
34+ } )
35+ }
3036 return
3137 }
3238
@@ -121,7 +127,7 @@ export function createOperator<ThisConfig extends IConfiguration>(
121127 ) => any
122128) : any {
123129 const operator = ( err , context , next , final ) => {
124- startDebugOperator ( type , name , context )
130+ operatorStarted ( type , name , context )
125131 let asyncTimeout = setTimeout ( ( ) => {
126132 context . execution . emit ( EventType . OPERATOR_ASYNC , {
127133 ...context . execution ,
@@ -148,19 +154,19 @@ export function createOperator<ThisConfig extends IConfiguration>(
148154 )
149155 const nextWithPath = createNextPath ( next )
150156 options . path . operator ( err , newContext , ( ...args ) => {
151- stopDebugOperator ( context , args [ 1 ] . value )
157+ operatorStopped ( context , args [ 1 ] . value )
152158 nextWithPath ( ...args )
153159 } )
154160 } else {
155- stopDebugOperator ( context , err || value , {
161+ operatorStopped ( context , err || value , {
156162 isSkipped : err ? true : options . isSkipped ,
157163 } )
158164 next ( err , createContext ( context , value ) )
159165 }
160166 } ,
161167 ( err , value ) => {
162168 clearTimeout ( asyncTimeout )
163- stopDebugOperator ( context , err || value , {
169+ operatorStopped ( context , err || value , {
164170 isSkipped : Boolean ( err ) ,
165171 isIntercepted : ! err ,
166172 } )
@@ -169,7 +175,7 @@ export function createOperator<ThisConfig extends IConfiguration>(
169175 )
170176 } catch ( error ) {
171177 clearTimeout ( asyncTimeout )
172- stopDebugOperator ( context , context . value , {
178+ operatorStopped ( context , context . value , {
173179 error,
174180 } )
175181 next ( error , createContext ( context , context . value ) )
@@ -200,7 +206,7 @@ export function createMutationOperator<ThisConfig extends IConfiguration>(
200206 ) => any
201207) : any {
202208 const operator = ( err , context , next , final ) => {
203- startDebugOperator ( type , name , context )
209+ operatorStarted ( type , name , context )
204210 const mutationTree = context . execution . getMutationTree ( )
205211 if ( ! IS_PRODUCTION ) {
206212 mutationTree . onMutation ( ( mutation ) => {
@@ -229,14 +235,14 @@ export function createMutationOperator<ThisConfig extends IConfiguration>(
229235 : context . execution . scopeValue ( context . value , mutationTree ) ,
230236 ( err , value , options = { } ) => {
231237 clearTimeout ( asyncTimeout )
232- stopDebugOperator ( context , err || value , {
238+ operatorStopped ( context , err || value , {
233239 isSkipped : err ? true : options . isSkipped ,
234240 } )
235241 next ( err , createContext ( context , value ) )
236242 } ,
237243 ( err , value ) => {
238244 clearTimeout ( asyncTimeout )
239- stopDebugOperator ( context , err || value , {
245+ operatorStopped ( context , err || value , {
240246 isSkipped : Boolean ( err ) ,
241247 isIntercepted : ! err ,
242248 } )
@@ -268,7 +274,7 @@ export function createMutationOperator<ThisConfig extends IConfiguration>(
268274 }
269275 } catch ( error ) {
270276 clearTimeout ( asyncTimeout )
271- stopDebugOperator ( context , context . value , {
277+ operatorStopped ( context , context . value , {
272278 error,
273279 } )
274280 next ( error , createContext ( context , context . value ) )
0 commit comments