question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Host should not return a redirect source file from `getSourceFile`

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When using webpack-dev-server in --watch mode and you make a change the build process throws the following error:

ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
    at tryReuseStructureFromOldProgram (C:\Users\me\repo\web-app-angular\node_modules\typescript\lib\typescript.js:74285:26)
    at Object.createProgram (C:\Users\me\repo\web-app-angular\node_modules\typescript\lib\typescript.js:73988:34)
    at AngularCompilerProgram._updateProgramWithTypeCheckStubs (C:\Users\me\repo\web-app-angular\packages\compiler-cli\src\transformers\program.ts:508:26)
    at C:\Users\me\repo\web-app-angular\packages\compiler-cli\src\transformers\program.ts:187:18
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Expected behavior

It should not throw an error and compile the code as usual.

Minimal reproduction of the problem with instructions

See this PR for more info: https://github.com/dherges/ng-packagr/pull/637

What is the motivation / use case for changing the behavior?

Webback watch mode is useless if you have to restart it after each change.

Environment


Angular version: 5.2.6 | 6.0.0-beta.6

 
For Tooling issues:
- Node version: 8.9.4
- Platform:  Windows

Others:

Typescript: 2.6.2
Webpack: 4.0.1
Webpack-dev-server: 3.1.0

Conclusion

This seems to work. Not sure what else it will break though. Added the redirectInfo fix from the PR i referenced.

// program.js:485 (compiled file)
tmpProgram.getSourceFiles().forEach(function (sf) {
    if (_this.hostAdapter.isSourceFile(sf.fileName)) {
        if (sf['redirectInfo']) {
            sf = sf['redirectInfo'].redirectTarget;
        }
        sourceFiles.push(sf.fileName);
    }
    if (util_1.TS.test(sf.fileName) && !util_1.DTS.test(sf.fileName)) {
        tsFiles.push(sf.fileName);
    }
});
// program.ts:568 (source file)
// note: redirectInfo does not exists on ts.SourceFile hence the any.
tmpProgram.getSourceFiles().forEach(sf => {
  if (this.hostAdapter.isSourceFile(sf.fileName)) {
      if ((sf as any)['redirectInfo']) {
          sf = (sf as any)['redirectInfo'].redirectTarget;
      }
    sourceFiles.push(sf.fileName);
  }
  if (TS.test(sf.fileName) && !DTS.test(sf.fileName)) {
    tsFiles.push(sf.fileName);
  }
});
console.log(sf.fileName);
console.log(sf['redirectInfo'].redirectTarget.fileName);
--------------------------
C:/Users/me/repo/web-app-angular/node_modules/@types/webpack/node_modules/source-map/source-map.d.ts
C:/Users/me/repo/web-app-angular/node_modules/@types/uglify-js/node_modules/source-map/source-map.d.ts
--------------------------

Edit: It seems like my ticket is not clear enough in pointing out the issue based on the new posts in this thread. The issue happens due to identical *.d.ts file found via two paths in the compilation. In plain english: The packages uses the same dependency that includes a definition file.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:60
  • Comments:55 (11 by maintainers)

github_iconTop GitHub Comments

40reactions
JonWallstencommented, May 27, 2019

@alexeagle Will this ever be looked at? It’s easily reproducible, seems to be a simple fix and affects a lot of users based on the number of “Thumbs up”. The error still occurs in Angular 8 RC.

33reactions
piernikcommented, Oct 19, 2018

After updating @angular to 7.0.0 and ng-packagr to 4.3.1 I have this error as well every time I change something in code during serve --aot mode: ERROR in Debug Failure. False expression: Host should not return a redirect source file from 'getSourceFile'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 7 : "ng serve --aot" fails the after a file change
False expression: Host should not return a redirect source file from `getSourceFile` i 「wdm」: Failed to compile.
Read more >
host should not return a redirect source file from `getSourceFile`
fix: host should not return a redirect source file from `getSourceFile`
Read more >
Switching from angular2-template-loader to @ngtools/webpack
Host should not return a redirect source file from getSourceFile. There's an open issue on Github for this error and it suggests patching ......
Read more >
src/compiler/program.ts - TypeScript - Fossies
originalFileName)) return redirect; 1436 1437 // The originalFileName could not be actual source file name if file found was d.ts from ...
Read more >
ngx-bootstrap: Angular Ivy is here - Valor Software
The host should not return a redirect source file from 'getSourceFile' (related Angular Issue). In the Angular 8, they've changed the TypeScript output...
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found