Skip to content

[3.0] Typescript --build causes infinite loop of compiling #26612

Closed

Description

@natew

Expected behavior:

Using --build should not loop.

Actual behavior:

What is frustrating about reporting this issue is this is happening a big-ish monorepo and I've tried about 20 different configuration setups now and they seem to break in different ways so I it's hard to really point out what's causing this. It sometimes acts nicely and then at some point I'll see it going through an endless loop and kill it, but I often have little clue as to which save started the loop or which config caused which loop.

Once it does happen I can replicate it very consistently, and it happens often. Though replicating it in code for you would be really hard, as it's a large and layered monorepo.

Basically I have a monorepo with about 30 packages, 6 top level apps, and a lot of "middle" level packages along the way. Oftentimes packages use the same leaf-level ones.

I have validated many things: All the configs are valid, they all build properly by themselves and I can run just about any of them in order. There are no type errors.

I wrote a little more on it here: #25600 (comment)

Here's an example --verbose log:

[13:22:47] File change detected. Starting incremental compilation...

[13:22:48] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-electron/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/css/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/config/tsconfig.json'...

[13:22:58] File change detected. Starting incremental compilation...

[13:22:58] Found 0 errors. Watching for file changes.

[13:22:58] File change detected. Starting incremental compilation...

[13:22:58] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-electron/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/css/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/config/tsconfig.json'...

[13:23:08] File change detected. Starting incremental compilation...

[13:23:08] Found 0 errors. Watching for file changes.

[13:23:08] File change detected. Starting incremental compilation...

[13:23:08] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-electron/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/css/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/config/tsconfig.json'...

[13:23:18] File change detected. Starting incremental compilation...

[13:23:18] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-electron/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/css/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/config/tsconfig.json'...

[13:23:28] File change detected. Starting incremental compilation...

[13:23:28] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-electron/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/css/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/config/tsconfig.json'...

[13:23:38] File change detected. Starting incremental compilation...

[13:23:38] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-electron/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/css/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/config/tsconfig.json'...

[13:23:48] File change detected. Starting incremental compilation...

[13:23:48] Found 0 errors. Watching for file changes.

message TS6358: Building project '/Users/nw/projects/motion/orbit/packages/mobx-bridge/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/stores/tsconfig.json'...

message TS6358: Building project '/Users/nw/projects/motion/orbit/app/orbit-desktop/tsconfig.json'...

Activity

  1. RyanCavanaugh commented on Aug 24, 2018

    @RyanCavanaugh
    Member

    I think Sheetal Nandi (@sheetalkamat) 's work to refactor the build queue may fix this, but need to verify

  2. natew commented on Aug 24, 2018

    @natew
    Author

    Ok, got a better view of the loop by running a different watcher. I edited a file in a deep nested package (the config one) that is used by a lot of other ones:

    image

    Not sure how helpful but it keeps going after this for a while.

  3. sheetalkamat commented on Aug 28, 2018

    @sheetalkamat
    Member

    Can you please try typescript@next generated tonight (that is anything that's equal to or above typescript@3.1.0-dev.20180829) to see if it fixes the issue. thanks

  4. natew commented on Aug 29, 2018

    @natew
    Author

    Seems to get stuck now where it didn't before. It says file change detected, but then doesn't finish compiling.

    image

    Separately am seeing it says now that some style definitions don't exist when they show in the .d.ts and were working in 3.0, which may be causing trouble saving as it doesn't like to save unless everything is compiled without error (is that a known bug too?):

    image

    image

  5. sheetalkamat commented on Aug 29, 2018

    @sheetalkamat
    Member

    You are running into queue not being reset correctly. #26742 should fix that.

  6. sheetalkamat commented on Aug 30, 2018

    @sheetalkamat
    Member

    Nate Wienert (@natew) can you give typescript@next a try to see if things are working for you. Thanks

  7. natew commented on Aug 31, 2018

    @natew
    Author

    I actually don't see any file output file now when I change something in the parent app. It shows it noticed an update but nothing changes. Even deleting it's out folder and re-running tsc --build --watch nothing is output.

    I'm seeing a new error in one of the packages, it's interesting. Maybe that's blocking build.

    I have a pattern where I import a package and return its result like so:

    import x from 'x'
    
    return function y() {
      return x(123)
    }

    And then in x it has something like:

    export default x(): Color {
      // ...
    }

    For some reason now in the first output .d.ts file I see an error where it tries to inline that Color type but it doesn't exist (notice red line):

    image

  8. natew commented on Aug 31, 2018

    @natew
    Author

    Ay. So downgraded and noticed both errors are happening on 3.0.3. I don't think they were happening on 3.0.1 but don't have so much time to debug. I ended up monkeypatching the bad type export.

    Is it true deleting the build folder and then running tsc --build --watch doesn't output anything? And then hitting save on a file does nothing too? I had to go back and run tsc --build which output properly and then re-run watch, and then saving.

    Edit: Actually that worked once, but now it gets stuck again after on successful save (on 3.0.3):

    image

  9. sheetalkamat commented on Aug 31, 2018

    @sheetalkamat
    Member

    The multiple File change detected should be fixed by #26782
    Note that none --watch behavior (with or without --build) watch output folders as of now. so only changes in input are watched at moment.

  10. sheetalkamat commented on Sep 4, 2018

    @sheetalkamat
    Member

    Nate Wienert (@natew) Can you please check with typescript@next if your issue is resolved. Thanks.

  11. natew commented on Sep 5, 2018

    @natew
    Author

    Yes, working great today. Thank you!

  12. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions