Skip to content
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

Pulumi hangs when there is a tsconfig.json in parent folder (even for JavaScript projects) #1772

Closed
lukehoban opened this issue Aug 14, 2018 · 1 comment · Fixed by #1857
Closed
Assignees
Milestone

Comments

@lukehoban
Copy link
Member

When I tried to pulumi update a program in ~/go/src/github.com/pulumi/examples/aws-js-webserver, defined in JavaScript, not TypeScript - the pulumi update hung during preview with node pegging a core.

Turns out, this was because I had a tsconfig.json in ~/. That apparently causes tsnode to see that as the root of my project and to try to compile everything underneath my home directory.

Not sure what to do about this, but this is a really easy mistake to make and leads to a very bad experience.

@lukehoban lukehoban added this to the 0.17 milestone Aug 14, 2018
@ellismg
Copy link
Contributor

ellismg commented Aug 14, 2018

So an easy thing to do would be to change how we invoke ts-node to only read a project file in the case where one was located in your main folder (i.e. next to your package.json).

In a similar vain, we could consider inspecting the root of your main folder and in cases where an index.ts is not present, just not even register ts-node. Not sure if that ends up being too much magic.

ellismg added a commit that referenced this issue Aug 31, 2018
If a `tsconfig.json` file is not present at the root of the pulumi
project, ts-node will look up the directory tree to see if there is
one. If there is, it will treat that as the root of the project. While
reasonable for some cases, this isn't the behavior we want for our use
of ts-node. We actaully set compiler options such that in the common
case you don't even need a `tsconfig.json` and for pure JavaScript
projects, there wouldn't be a `tsconfig.json` file.

In both of these cases, there's a big footgun waiting. For example in
#1772 we ran into a case where there was a tsconfig.json
file in $HOME, causing the entirety of $HOME to be analysized by
TypeScript which made it look like Pulumi hung.

To address this, tell ts-node to not use a project in cases where
there is not a `tsconfig.json` at the root of the project.

Fixes #1772
ellismg added a commit that referenced this issue Aug 31, 2018
If a `tsconfig.json` file is not present at the root of the Pulumi
project, ts-node will look up the directory tree to see if there is
one. If there is, it will treat that as the root of the project. While
reasonable for some cases, this isn't the behavior we want for our use
of ts-node. We actually set compiler options such that in the common
case you don't even need a `tsconfig.json` and for pure JavaScript
projects, there wouldn't be a `tsconfig.json` file.

In both of these cases, there's a big foot-gun waiting. For example in
#1772 we ran into a case where there was a tsconfig.json
file in $HOME, causing the entirety of $HOME to be analyzed by
TypeScript which made it look like Pulumi hung.

To address this, tell ts-node to not use a project in cases where
there is not a `tsconfig.json` at the root of the project.

Fixes #1772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants