Skip to content

FatalDiagnosticError is being thrown by the compiler when removing signal input or Child component is not exported #27045

Closed

Description

@JeanMeche

Command

build, serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

17.1

Description

The CLI throws the following error when running the provided repro.

[✘ [ERROR] Cannot read properties of null (reading 'errors') [plugin angular-compiler]

    node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:199:32:
      199 │                 if (diagnostics.errors?.length) {
          ╵                                 ^

    at /Users/kyro/Developer/web/angular-projects/next/node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:199:33
    at async /Users/kyro/Developer/web/angular-projects/next/node_modules/esbuild/lib/main.js:1350:22
    at async Promise.all (index 0)
    at async requestCallbacks.on-start (/Users/kyro/Developer/web/angular-projects/next/node_modules/esbuild/lib/main.js:1348:5)
    at async handleRequest (/Users/kyro/Developer/web/angular-projects/next/node_modules/esbuild/lib/main.js:732:11)

  This error came from the "onStart" callback registered here:

    node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:81:18:
      81 │             build.onStart(async () => {
         ╵                   ~~~~~~~

    at setup (/Users/kyro/Developer/web/angular-projects/next/node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:81:19)
    at async handlePlugins 

Minimal Reproduction

Repro : https://github.com/jeanmeche/next

The issue doesn't not happen when either

  • The Child component is exported
  • Signal input is removed.

While there is maybe an issue on the signal implementation part, the CLI probably shouldn't throw the way it does.

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.1.2
Node: 18.17.0
Package Manager: npm 9.6.7
OS: darwin x64

Angular: 17.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.2
@angular-devkit/build-angular   17.1.2
@angular-devkit/core            17.1.2
@angular-devkit/schematics      17.1.2
@schematics/angular             17.1.2
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.3

Activity

  1. ducin commented on Feb 5, 2024

    @ducin
  2. JeanMeche commented on Feb 6, 2024

    @JeanMeche
    MemberAuthor

    Seems like there was a related issue on the FW repo : angular/angular#53678

    There framework throwing an error is one thing, but it should thrown correctly by the application builder.

  3. alan-agius4 commented on Feb 6, 2024

    @alan-agius4
    Collaborator

    This is a bug in the compiler as calling compilation.diagnoseFiles() is retuning undefined which should never happen.

  4. changed the title [-]CLI throws unexpectedly[/-] [+]`compilation.diagnoseFiles()` is retuning `undefined`[/+] on Feb 6, 2024
  5. added this to the needsTriage milestone on Feb 6, 2024
  6. alxhub commented on Feb 6, 2024

    @alxhub
    Member

    @alan-agius4 which compilation is that? I don't think we have a diagnoseFiles function anywhere in ngc.

  7. alan-agius4 commented on Feb 6, 2024

    @alan-agius4
    Collaborator

    @alxhub, apologies, I did not initial realize that it's an Angular CLI implementation.

  8. removed this from the needsTriage milestone on Feb 6, 2024
  9. transferred this issue fromangular/angularon Feb 6, 2024
  10. alan-agius4 commented on Feb 7, 2024

    @alan-agius4
    Collaborator

    This is similar to : angular/angular#53678 where the compiler is throwing a FatalDiagnosticError on the typecheck file. Now since this is not an instance of Error the Piscina will assume that an error did not occur and will not exit successfully and not with an error.

    FatalDiagnosticError {
      code: 3004,
      node: <ref *1> SourceFileObject {
        pos: 0,
        end: 0,
        flags: 0,
        modifierFlagsCache: 0,
        transformFlags: 0,
        parent: undefined,
        kind: 312,
        statements: [ pos: 0, end: 0, hasTrailingComma: false, transformFlags: 0 ],
        endOfFileToken: TokenObject {
          pos: 0,
          end: 0,
          flags: 0,
          modifierFlagsCache: 0,
          transformFlags: 0,
          parent: [Circular *1],
          kind: 1
        },
        text: '',
        fileName: '/next/src/main.ngtypecheck.ts',
        path: '',
        resolvedPath: '',
        originalFileName: '',
        languageVersion: 99,
        languageVariant: 0,
        scriptKind: 3,
        isDeclarationFile: false,
        hasNoDefaultLib: false,
        locals: undefined,
        nextContainer: undefined,
        endFlowNode: undefined,
        nodeCount: 2,
        identifierCount: 0,
        symbolCount: 0,
        parseDiagnostics: [],
        bindDiagnostics: [],
        bindSuggestionDiagnostics: undefined,
        lineMap: undefined,
        externalModuleIndicator: undefined,
        setExternalModuleIndicator: [Function: setExternalModuleIndicator],
        pragmas: Map(0) {},
        checkJsDirective: undefined,
        referencedFiles: [],
        typeReferenceDirectives: [],
        libReferenceDirectives: [],
        amdDependencies: [],
        commentDirectives: undefined,
        identifiers: Map(0) {},
        packageJsonLocations: undefined,
        packageJsonScope: undefined,
        imports: undefined,
        moduleAugmentations: undefined,
        ambientModuleNames: undefined,
        classifiableNames: undefined,
        impliedNodeFormat: undefined,
        jsDocParsingMode: 0,
        [Symbol(AbsolutePath)]: '/next/src/main.ngtypecheck.ts'
      },
      message: {
        category: 3,
        code: 0,
        messageText: 'Unable to import symbol Child.',
        next: [ [Object] ]
      },
      relatedInformation: [
        {
          category: 3,
          code: 0,
          file: [SourceFileObject],
          start: 117,
          length: 130,
          messageText: 'The symbol is declared here.'
        }
      ],
      _isFatalDiagnosticError: true
    }
    

    From my understanding the Angular compiler should never surface a FatalDiagnosticError, and it should be transformed to a diagnostics internally. Is this correct @alxhub / @JoostK? As otherwise, we'd need to expose FatalDiagnosticError and isFatalDiagnosticError APIs from the Compiler and make them accessable to the Angular CLI.

    So in my eyes there are 2 problems here:

    1. The error points to a typecheck file
    2. The check in https://github.com/angular/angular/blob/f39cb064183d984254bdf4e41b61d3dc9379738a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts#L457-L461 should be changed so that if it's a FatalDiagnosticError it is not thrown.

    //cc @devversion, who modified the above code recently in angular/angular@760b1f3

  11. changed the title [-]`compilation.diagnoseFiles()` is retuning `undefined`[/-] [+]`FatalDiagnosticError` is being thrown by the compiler when using signal input or `Child` component is not exported[/+] on Feb 7, 2024
  12. changed the title [-]`FatalDiagnosticError` is being thrown by the compiler when using signal input or `Child` component is not exported[/-] [+]`FatalDiagnosticError` is being thrown by the compiler when removing signal input or `Child` component is not exported[/+] on Feb 7, 2024
  13. self-assigned this
    on Feb 7, 2024
  14. devversion commented on Feb 7, 2024

    @devversion
    Member

    Yeah, so to clarify: Before my "fix", we did not catch fatal diagnostics at all when collecting extended diagnostics. This surfaced these super hard to debug errors when e.g. a class was not exported and the TCB code couldn't be generated at all- the same is used for extended diagnostics.

    It looks like as part of my fix, I did forget returning early and therefore diagnostics are converted properly now (before they weren't)- but we are still throwing. So my fix was a noop. I'm sending a fix- but the root causes are still:

    • Need to fix that we are not throwing- like I was attempting to do with my PR
    • CLI should be improved to not swallow runtime exceptions error. It was non-trivial to debug this back then
  15. alan-agius4 commented on Feb 7, 2024

    @alan-agius4
    Collaborator

    The error is being swallowed as FatalDiagnosticError is not Error which causes the worker to exit without an error. See check in piscinajs. As per convo with @devversion, he will try to make these as errors.

  16. alan-agius4 commented on Feb 7, 2024

    @alan-agius4
    Collaborator
  17. angular-automatic-lock-bot commented on Mar 9, 2024

    @angular-automatic-lock-bot

    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.

  18. locked and limited conversation to collaborators on Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions