Created
          July 1, 2021 21:43 
        
      - 
      
- 
        Save a-type/faead638a35fe08f56eff2336b65502a to your computer and use it in GitHub Desktop. 
    Abort controller synchronous call test
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var controller = new AbortController(); | |
| fetch('/', { signal: controller.signal }) | |
| .then(res => res.text()) | |
| .then(text => console.log(text)); | |
| // busywait for a while, should keep the thread busy until the request | |
| // completes. | |
| let i = 0; while (i < 100000) { | |
| i++; | |
| console.log(i); | |
| } | |
| controller.abort(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ... numbers ... | |
| 9994 | |
| 9995 | |
| 9996 | |
| 9997 | |
| 9998 | |
| 9999 | |
| 10000 | |
| undefined | |
| index:1 Uncaught (in promise) DOMException: The user aborted a request. | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment