Closed DeborahK closed 4 years ago
Reminds me of https://github.com/angular/angular/issues/32213, but that's been fixed I think.
This is actually expected and it's not any different from that of previous versions with AOT compilations. It happens more often since version 9, because AOT has been turned on by default which results in more errors being caught during build time instead of runtime.
1) During AOT builds we only emit JS when there is no error. This results in the blank screen with a cannot get
error when the 1st compilation is not successful. https://github.com/angular/angular-cli/blob/348ebdd50cd434d871a8e52d0ee66479211f803b/packages/ngtools/webpack/src/angular_compiler_plugin.ts#L1399-L1413
2) The black overlay is shown when you had the application open in a browser and the above occurred.
3) When there is a compilation error on a rebuild we don't "block" the compilation, to have faster rebuild times, by the means of the "forkTypeChecker" (https://angular.io/cli/build), the downside of this is that errors will only be shown in the terminal. A user can opt-out of this by disabling the "forkTypeChecker" and they will get the black overlay, but this comes at the cost of rebuild times.
Overall we definitely need to look into this more and evaluate how we can improve/align the DX around errors, and see how others are using fork type checking and reporting errors back to the browser via an overlay such as: https://github.com/ypresto/fork-ts-checker-async-overlay-webpack-plugin/blob/master/src/index.ts https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/
My current suggestion would be to use the terminal as the source of truth for build related errors.
Edit: fork-ts-checker-webpack-plugin does suffer from the same "issue" - https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#options (see async
option description)
Thank you so much for looking into this and providing such detailed feedback.
This is going to really confuse beginners, who may think:
I'd minimally suggest that this be included in the documentation: That they could see three different results depending on when they run the compiler and that the focus should be on the terminal window.
This should include the text of the error (in the case of #1) so that hopefully it would show up in search results.
This is what I had added to my course for beginners the first time I show them what will happen if they forget a step (such as forgetting to add a component to a module):
What youβll see in the browser depends on when you last started the compiler with
npm start
. β’You may see the app component page title, but not our product list component. In this case, the browser displayed the last successfully compiled files, so you donβt see our new component. Using the F12 tools, no error is shown. β’ Or, you may see the message βCannot GETβ. Opening the developer tools, you see the error is: βFailed to load resource: the server responded with a status of 404 (Not Found)β. You may see this error whenever the application canβt compile and therefore canβt serve the files to the browser. β’ Or you may get lucky and see the actual error: βpm-products is not a known elementβ. In any case, your best option is to go back to VS Code and view the terminal window to see any compilation messages. Whenever you see unexpected results or errors in the browser, check the VS Code terminal window for compile issues.
Thank you again!
Yes i am having similar issue sometime i get can not get / then i look into web browser console then i look into terminal for errors. This is started in NG9 (probably of AOT)
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
π Bug report
Command (mark with an
x
)Is this a regression?
Yes. In Angular v8 and before, the browser would consistently show errors, regardless of when you executed `npm start` ### Description What you see in the browser when you have an error depends on when you execute `npm start`. You may get this: ![image](https://user-images.githubusercontent.com/7987365/79477249-dc043b00-7fbe-11ea-9d87-d084a9a6615f.png) No error shown. Appears to display the last successfully compiled files. You may get this: ![image](https://user-images.githubusercontent.com/7987365/79477354-f76f4600-7fbe-11ea-885f-8e2205951a3a.png) Get error. This is very unhelpful, especially for Angular beginners. This appears if you run `npm start` after making an error. It appears that it cannot serve any files in this case. Or you may get lucky and get this: ![image](https://user-images.githubusercontent.com/7987365/79477536-2a193e80-7fbf-11ea-80cb-bf6c32213bea.png) This is much more helpful, but not consistently shown. ## π¬ Minimal ReproductionThis is one example, but it happens with many different errors, such as forgetting to add a component to an Angular module:
1) ng new APM 2) cd APM 3) code . 4) Run npm start 5) Add the following line to the template:
<input type='text' [(ngModel)]='listFilter' />
(This is an error because we don't have listFilter defined and we have not imported FormsModule.) 6) View the browser. No error. 7) Using the F12 tools, you see the ngModel error. 8) Stop the compiler. 9) Restart the compiler and you see the black background and an error in the browser. I assume this is the behavior that we should see in every case. 10) Remove the added input line. The code does not recompile and the browser still shows the error. So it appears as if it was not fixed. 11) Stop the compiler. 12) Add the above input element again (step #5) 13) Start the compiler. 14) This time you'll see thecannot get
error.So depending on when the
npm start
is executed, the developer will see different results, some of which, like thecannot get
error, provide no information in the browser as to what is wrong.π₯ Exception or Error
π Your Environment
Anything else relevant?
Similar issues: https://github.com/angular/angular-cli/issues/15887