- 
                Notifications
    You must be signed in to change notification settings 
- Fork 70
          fix: don't error out while catching a buildStart error
          #422
        
          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
          
     Merged
      
      
    
      
        
          +8
        
        
          −1
        
        
          
        
      
    
  
Conversation
  
    
      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
    
  
  
    
    - per in-line comment, if an error occurs during `buildStart` initialization, then the `cache` may not exist yet during `buildDone`
  - since we now use `context.error` instead of `throw` during initialization (from the `options` -> `buildStart` change), `buildEnd` will run during initialization
    - and the `cache` var is initialized in `buildStart` as well, so if an error occurs before then, the `cache` won't exist
      - we should gracefully handle this in all cases, since it's possible that even creating the `cache` could throw an error
- this error was hiding the underlying error, which was problematic for DX as well as bug reports (see my issue follow-up)
- add an integration test for `tsconfig` to make sure this code works
  - while this is similar to the previous `tsconfig` integration tests (that were moved to unit tests), this covers all cases of `buildStart` errors, and is not specific to the different `tsconfig` errors (unlike the unit tests)
  - this test will fail without the source code changes in this commit
    | Hi this is currently causing issues in one of my projects. Could you push this out please? | 
      
        
      
      
  
    1 task
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    kind: dx
  Improvements to dev experience, e.g. error messages, logging, external-facing docs, etc 
  
    kind: regression
  Specific type of bug -- past behavior that worked is now broken 
  
    scope: cache
  Related to the cache 
  
    scope: tests
  Tests could be improved. Or changes that only affect tests 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Summary
If an error occurs during the
buildStarthook, make sure that thebuildEndhook doesn't hide the error with its own errorbuildDonefunc had an uninitializedcachevar, as it's initialized inbuildStartafter this thrown errorTypeError: Cannot read property 'done' of undefined(cache.done()) #421TypeError: Cannot read property 'done' of undefined(cache.done()) #421 (comment)ConsoleContextentirely by usingbuildStart#414 + refactor(cache): simplify creating / using thecachevar #415Details
per in-line comment, if an error occurs during
buildStartinitialization, then thecachemay not exist yet duringbuildDonecontext.errorinstead ofthrowduring initialization (from theoptions->buildStartchange),buildEndwill run during initialization - and thecachevar is initialized inbuildStartas well, so if an error occurs before then, thecachewon't exist - we should gracefully handle this in all cases, since it's possible that even creating thecachecould throw an errorthis error was hiding the underlying error, which was problematic for DX as well as bug reports (see my issue follow-up)
add an integration test for
tsconfigto make sure this code workstsconfigintegration tests (that were moved to unit tests), this covers all cases ofbuildStarterrors, and is not specific to the differenttsconfigerrors (unlike the unit tests)Misc Notes
Would be good for a patch release! Especially as this error currently hides actual errors 😕