vercel / turbo

Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo.
https://turbo.build
MIT License
25.53k stars 1.74k forks source link

Turborepo@2 is no longer playing well with vscode debug terminal #8580

Open anthonyshew opened 1 week ago

anthonyshew commented 1 week ago

Discussed in https://github.com/vercel/turbo/discussions/8388

Originally posted by **notaphplover** June 8, 2024 ### Summary I'm not sure about creating an issue about this, but `turborepo@2` no longer play well with vscode debug terminal. Running a task in `turborepo@1` (including `turborepo@1.13`) in a vscode debug terminal triggers vscode debug breakpoints, but this behavior no longer happens when trying `turborepo@2`. We can still use more traditional ways to debug a node application (the inspector protocol works like a charm), but the vscode debug terminal is such an straightforward approach I think it would be great to support it in turborepo. Is this behavior expected? Consider [this sample repo](https://github.com/notaphplover/turborepo-trap-issue) as an example. the task `foo:turbo` cannot be debugged using a javascript debug terminal unless `turbo@1` is installed. Setting `{ "ui": "stream" }` in the `turbo.json` config file does not solve the issue. ### Additional information I wonder if `turborepo@2` spawns child task in a different way `turborepo@1` does. Maybe https://github.com/microsoft/vscode-js-debug/issues/1101#issuecomment-915345492 is relevant. ### Example https://github.com/notaphplover/turborepo-trap-issue
anthonyshew commented 1 week ago

This is likely due to Strict Mode. The vscode-js-debug comment you've linked does seem relevant indeed.

In the meantime, you can run your turbo invocations with the Loose Mode flag, turbo run <tasks> --env-mode=loose and that should let through the environment variables required for the debugger to run as desired.

anthonyshew commented 1 week ago

For what it's worth, I had a moment so I went looking for the variable names and can't seem to locate them. If anyone is able to find them, please share!

weyert commented 1 week ago

Do you automatically accept NODE_*? E.g. NODE_OPTIONS, NODE_PATH or NODE_INSPECTOR_INFO etc? Or maybe even the VSCODE_* ones?

anthonyshew commented 1 week ago

The VSCODE ones are what I'm looking for! Where did you find them?

weyert commented 1 week ago

Oh here: https://github.com/microsoft/vscode-js-debug/blob/5b0f41dbe845d693a541c1fae30cec04c878216f/src/targets/node/nodeLauncherBase.ts#L320

busbyk commented 1 week ago

This is likely due to Strict Mode. The vscode-js-debug comment you've linked does seem relevant indeed.

In the meantime, you can run your turbo invocations with the Loose Mode flag, turbo run <tasks> --env-mode=loose and that should let through the environment variables required for the debugger to run as desired.

This works for me. Was experiencing the same issue after upgrading to 2.0.3