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

Windows + tsx issue #7834

Open
1 task done
osztenkurden opened this issue Mar 25, 2024 · 7 comments
Open
1 task done

Windows + tsx issue #7834

osztenkurden opened this issue Mar 25, 2024 · 7 comments
Labels
area: windows Issues specifically reproducing on Windows kind: bug Something isn't working

Comments

@osztenkurden
Copy link

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/osztenkurden/turbo-tsx-googleapis-issue

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Windows

Which canary version will you have in your reproduction?

1.13.1-canary.0

Describe the Bug

Running turbo command, that invokes tsx watch FILE.ts, when FILE.ts includs reference from googleapis npm package results in no output, and no code being run. Removing watch flag makes it work properly. This worked properly on 1.12.5, and breaks on 1.13+.

Expected Behavior

Referencing googleapis in Typescript code should not freeze executing that file when run with tsx watch

To Reproduce

apps/backend/index.ts:

import { google } from 'googleapis';
console.log({ google })

apps/backend/package.json:

{
  "name": "api",
  "scripts": {
    "dev": "tsx watch src/index.ts",
    "build": "npx tsc"
  },
  "dependencies": {
    "googleapis": "^134.0.0"
  },
  "devDependencies": {
    "tsx": "^4.7.1",
    "typescript": "^4.9.4"
  }
}

./turbo.json:

{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["prebuild", "^build"],
      "outputs": ["output-file.txt", "dist/**"]
    },
    "prebuild": {},
    "lint": {},
    "type-check": {},
    "dev": {
      "cache": false
    }
  }
}

./package.json:

{
  "name": "my-turborepo",
  "description": "A barebones Turborepo example for working with Task Graphs.",
  "devDependencies": {
    "turbo": "canary"
  },
  "scripts": {
    "dev": "turbo run dev"
  },
  "packageManager": "[email protected]",
  "workspaces": [
    "apps/*",
    "packages/*"
  ]
}

Running npm run dev should result in logging the content of the google object from googleapis. Currently it hangs:
image

This works fine in 1.12.5, as well when manually executing npx tsc watch src/index.ts

Additional context

No response

@osztenkurden osztenkurden added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage owned-by: turborepo labels Mar 25, 2024
@NicholasLYang
Copy link
Contributor

Hi @osztenkurden, could you try adding "persistent": true to your dev task? Since it's a long running task, it needs that option to run correctly. Let me know if that helps!

@osztenkurden
Copy link
Author

@NicholasLYang Updated turbo.json so it looks like that:

{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["prebuild", "^build"],
      "outputs": ["output-file.txt", "dist/**"]
    },
    "prebuild": {},
    "lint": {},
    "type-check": {},
    "dev": {
      "cache": false,
      "persistent": true
    }
  }
}

However, still freezes.

@chris-olszewski
Copy link
Member

Can you confirm that the script works without the use of turbo?

I just tried cloning your repo and cd apps/backend && npm run dev resulted in the same behavior without use of turbo:
image-5

@tknickman tknickman added area: windows Issues specifically reproducing on Windows needs: author input and removed needs: triage New issues get this label. Remove it after triage labels Apr 1, 2024
@osztenkurden
Copy link
Author

osztenkurden commented Apr 1, 2024

@chris-olszewski Yep, it does, to be sure I verified both Terminal/CMD and Git Bash, both console log out:
image
image

Thats very weird, because it only starts happening on Turbo 13

I attached screens for working npm run dev in Terminal, Git Bash, and not working while using turbo

@chris-olszewski
Copy link
Member

Is that error message always present in your turbo runs?

@osztenkurden
Copy link
Author

osztenkurden commented Apr 2, 2024

No, forgot to run npm i for the workspaces / packages, I did it, warning went away and freezing still happens

@chris-olszewski chris-olszewski changed the title npx watch in dev script stops executing if file references googleapis Windows + tsx issue Apr 2, 2024
@chris-olszewski
Copy link
Member

chris-olszewski commented Apr 2, 2024

Okay, I've been able to track this down to a weird interaction with Windows, tsx watch, and tasks that aren't hooked up to a PTY.

Not exactly sure what the fix is at this time, but one workaround is to use the new experimental UI which allows for tasks on Windows to be hooked up to a pseudoterminal. Another workaround is to forcibly close stdin by changing the dev command to take NUL as stdin e.g. "dev": "tsx watch src/index.ts < NUL"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: windows Issues specifically reproducing on Windows kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants