Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for returned Promises reliably #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alxndrsn
Copy link

@alxndrsn
Copy link
Author

AppVeyor build is broken on NodeJS version 4. Node 4 hasn't been maintined since 2018, so can this failure be ignored?

@alxndrsn
Copy link
Author

An alternative approach might be to replace

        if (options.during.constructor.name === 'AsyncFunction') {                                                                                                           
          if (!seemsToExpectCallback) {                                                                                                                                      
            promiseOrResultMaybe = promiseOrResultMaybe.then(function(resultMaybe){                                                                                          
              didDuringFnAlreadyHalt = true;                                                                                                                                 
              proceed(undefined, resultMaybe);                                                                                                                               
            });//_∏_                                                                                                                                                         
          }//fi                                                                                                                                                               
          promiseOrResultMaybe.catch(function(e){ proceed(e); });//_∏_                                                                                                       
        } else {                                                                                                                                                             
          if (!seemsToExpectCallback) {                                                                                                                                      
            didDuringFnAlreadyHalt = true;                                                                                                                                   
            return proceed(undefined, promiseOrResultMaybe);                                                                                                                 
          }                                                                                                                                                                  
        } 

with

        if (!seemsToExpectCallback) {                                                                                                                                        
          try {                                                                                                                                                              
            const res = await promiseOrResultMaybe;                                                                                                                          
            didDuringFnAlreadyHalt = true;                                                                                                                                   
            return proceed(undefined, res);                                                                                                                                  
          } catch(err) {                                                                                                                                                     
            proceed(err);                                                                                                                                                    
          }                                                                                                                                                                  
        } 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants