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

feat: ensure PrefixedWriter is line buffered #7728

Merged
merged 2 commits into from Mar 14, 2024

Conversation

chris-olszewski
Copy link
Contributor

@chris-olszewski chris-olszewski commented Mar 13, 2024

Description

At the moment, it is currently the caller's responsibility to make sure that PrefixedWriter is only fed a single line at a time and that writes end with a newline.

If the caller doesn't do this output can be unexpected such as:

prefix > one
two
three

or

prefix1 > no newline prefix2 > my log line

We currently call this correctly since we read child output in a line buffered manner and inserting newlines if they're missing. With the move to richer output such as spinners we will no longer be waiting to see a newline to forward output.

This PR prepares us for that future by making PrefixedWriter itself a line buffered writer so callers will no longer need to worry about this.

Testing Instructions

Added unit tests for verifying that callers who write PrefixedWriter no longer need to ensure they write full lines.

Closes TURBO-2634

Copy link

vercel bot commented Mar 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview Mar 13, 2024 11:04pm
rust-docs ✅ Ready (Inspect) Visit Preview Mar 13, 2024 11:04pm
8 Ignored Deployments
Name Status Preview Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-gatsby-web ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-native-web ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-svelte-web ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-tailwind-web ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm
examples-vite-web ⬜️ Ignored (Inspect) Mar 13, 2024 11:04pm

Copy link
Contributor

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Mar 13, 2024

🟢 CI successful 🟢

Thanks

@chris-olszewski chris-olszewski marked this pull request as ready for review March 13, 2024 23:45
@chris-olszewski chris-olszewski requested a review from a team as a code owner March 13, 2024 23:45
@chris-olszewski chris-olszewski merged commit 0a3bf27 into main Mar 14, 2024
56 checks passed
@chris-olszewski chris-olszewski deleted the olszewski/feat_prefixed_writer_buffer branch March 14, 2024 15:52
chris-olszewski added a commit that referenced this pull request Mar 15, 2024
### Description

This PR adds an `App` widget and hooks it up to the task graph
execution. The use of the TUI is controlled by the
`TURBO_EXPERIMENTAL_UI` env var.

Note that the TUI is experimental so this current iteration does not
attempt to tackle the following issues in this PR:
- Proper integration with our `tracing` setup. Writing to stderr (or
stdout) naively will cause us to overwrite the TUI as the cursor is
probably not in the correct position. Currently the best way to run with
increased verbosity is to pipe stderr to a file e.g.
`TURBO_EXPERIMENTAL_UI=true turbo build -vv 2> /tmp/logs.txt`
- "Proper" signal handling. Since we have
[ISIG](https://man7.org/linux/man-pages/man3/termios.3.html) flagged off
we are in charge of generating a SIGINT when `Ctrl-C` is pressed. We
currently stop rendering the TUI and shut down on `Ctrl-C`, but we
should do a
[raise](https://man7.org/linux/man-pages/man3/raise.3.html)/Windows
equivalent. #7737
- Persistent configuration of enabling the TUI i.e. `turbo.json`
extension
- Proper interaction with existing flags that modify output e.g.
`--log-order`/`--output-logs`
 - Responding to terminal resizing events
- Final TUI state, already there are things I want to change e.g. have
task render red on failure or rainbow on cache hit
 - Interactive tasks: #7735

Note for reviewers: Each commit is pretty self contained and should be
reviewed on it's own.

### Testing Instructions

Primary thing that should be tested is that when `TURBO_EXPERIMENTAL_UI`
is not set, there aren't any behavior changes.
The primary place where behavior could change is us changing reading
task input to no longer be line based. This should be covered by #7728,
but it is still worth manually checking since our prysk tests do not
cover this codepath.

To test the TUI set `TURBO_EXPERIMENTAL_UI=true` and run `turbo`.



https://github.com/vercel/turbo/assets/4131117/9097dc07-c76a-40af-9a81-26fcb1c18a19
kodiakhq bot added a commit to weareinreach/TransMascFutures that referenced this pull request Mar 22, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [eslint-plugin-codegen](https://togithub.com/mmkal/eslint-plugin-codegen) | [`0.26.0` -> `0.28.0`](https://renovatebot.com/diffs/npm/eslint-plugin-codegen/0.26.0/0.28.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/eslint-plugin-codegen/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint-plugin-codegen/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint-plugin-codegen/0.26.0/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint-plugin-codegen/0.26.0/0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [eslint-plugin-turbo](https://togithub.com/vercel/turbo) ([source](https://togithub.com/vercel/turbo/tree/HEAD/packages/eslint-plugin-turbo)) | [`1.12.5` -> `1.13.0`](https://renovatebot.com/diffs/npm/eslint-plugin-turbo/1.12.5/1.13.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/eslint-plugin-turbo/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint-plugin-turbo/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint-plugin-turbo/1.12.5/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint-plugin-turbo/1.12.5/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [turbo](https://turbo.build/repo) ([source](https://togithub.com/vercel/turbo)) | [`1.12.5` -> `1.13.0`](https://renovatebot.com/diffs/npm/turbo/1.12.5/1.13.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/turbo/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/turbo/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/turbo/1.12.5/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/turbo/1.12.5/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [typescript](https://www.typescriptlang.org/) ([source](https://togithub.com/Microsoft/TypeScript)) | [`5.4.2` -> `5.4.3`](https://renovatebot.com/diffs/npm/typescript/5.4.2/5.4.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/typescript/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/typescript/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/typescript/5.4.2/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/typescript/5.4.2/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>mmkal/eslint-plugin-codegen (eslint-plugin-codegen)</summary>

### [`v0.28.0`](https://togithub.com/mmkal/eslint-plugin-codegen/releases/tag/v0.28.0)

[Compare Source](https://togithub.com/mmkal/eslint-plugin-codegen/compare/0.27.0...v0.28.0)

-   only consider codegen/codegen rules  [`4aafe14`](https://togithub.com/mmkal/eslint-plugin-codegen/commit/4aafe14)

### [`v0.27.0`](https://togithub.com/mmkal/eslint-plugin-codegen/releases/tag/0.27.0)

[Compare Source](https://togithub.com/mmkal/eslint-plugin-codegen/compare/0.26.0...0.27.0)

#### What's Changed

-   generalise markdown-from-jsdoc by [@&#8203;mmkal](https://togithub.com/mmkal) in [mmkal/eslint-plugin-codegen#25

**Full Changelog**: mmkal/eslint-plugin-codegen@0.26.0...0.27.0

</details>

<details>
<summary>vercel/turbo (eslint-plugin-turbo)</summary>

### [`v1.13.0`](https://togithub.com/vercel/turbo/releases/tag/v1.13.0): Turborepo v1.13.0

[Compare Source](https://togithub.com/vercel/turbo/compare/v1.12.5...v1.13.0)



#### What's Changed

##### Docs

-   s/the your/the/ by [@&#8203;steveluscher](https://togithub.com/steveluscher) in [vercel/turbo#7669
-   s/mental/model/ by [@&#8203;steveluscher](https://togithub.com/steveluscher) in [vercel/turbo#7668
-   Fix typos in docs & turborepo-lsp by [@&#8203;Dann1y](https://togithub.com/Dann1y) in [vercel/turbo#7702
-   docs: Update testing configuration documentation for clarity by [@&#8203;sooster910](https://togithub.com/sooster910) in [vercel/turbo#7683
-   docs: change texts from lint to type-check by [@&#8203;devjiwonchoi](https://togithub.com/devjiwonchoi) in [vercel/turbo#7698
-   `scan` command doc. by [@&#8203;anthonyshew](https://togithub.com/anthonyshew) in [vercel/turbo#6770
-   Docs: add references to TURBO_CACHE_DIR environment variable by [@&#8203;weyert](https://togithub.com/weyert) in [vercel/turbo#7632
-   Use hardcoding. by [@&#8203;anthonyshew](https://togithub.com/anthonyshew) in [vercel/turbo#7792
-   docs: document new ui configuration options by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7803

##### create-turbo

-   publish 1.13.0-canary.2 to registry by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7787

##### eslint

-   Support import.meta.env in eslint-plugin-turbo by [@&#8203;jamesbvaughan](https://togithub.com/jamesbvaughan) in [vercel/turbo#7781

##### [@&#8203;turbo/repository](https://togithub.com/turbo/repository)

-   fix([@&#8203;turbo/repository](https://togithub.com/turbo/repository)): Remove custom type so nap can serialize it by [@&#8203;mehulkar](https://togithub.com/mehulkar) in [vercel/turbo#7650
-   chore([@&#8203;turbo/repository](https://togithub.com/turbo/repository)): bump to 0.0.1-canary.9 by [@&#8203;mehulkar](https://togithub.com/mehulkar) in [vercel/turbo#7652
-   refactor(turborepo): Renaming -PackageDetector to -PackageChangeMapper by [@&#8203;NicholasLYang](https://togithub.com/NicholasLYang) in [vercel/turbo#7655
-   chore([@&#8203;turbo/repository](https://togithub.com/turbo/repository)): show current version when publishing by [@&#8203;mehulkar](https://togithub.com/mehulkar) in [vercel/turbo#7679
-   chore([@&#8203;turbo/repository](https://togithub.com/turbo/repository)): bump to 0.0.1-canary.10 by [@&#8203;mehulkar](https://togithub.com/mehulkar) in [vercel/turbo#7680

##### Examples

-   Bug fix on with-tailwind example by [@&#8203;zsh77](https://togithub.com/zsh77) in [vercel/turbo#7584
-   Improvements on kitchen-sink example by [@&#8203;zsh77](https://togithub.com/zsh77) in [vercel/turbo#7641
-   Bug fix on with rollup by [@&#8203;zsh77](https://togithub.com/zsh77) in [vercel/turbo#7651
-   fix(examples): avoid clearing screen when using vite by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7783
-   Bug fix on kitchen-sink example by [@&#8203;zsh77](https://togithub.com/zsh77) in [vercel/turbo#7624
-   fix(ci): fix examples CI check by [@&#8203;tknickman](https://togithub.com/tknickman) in [vercel/turbo#7801

##### Changelog

-   chore: clean up silent flag impl by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7643
-   chore: silence lint warnings from vt100 crate by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7647
-   chore: rename vendored vt100 crate by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7649
-   feat: Add success rate telemetry for login by [@&#8203;Zertsov](https://togithub.com/Zertsov) in [vercel/turbo#7656
-   chore(turborepo): Move PackageChangeMappers to turborepo-repository by [@&#8203;NicholasLYang](https://togithub.com/NicholasLYang) in [vercel/turbo#7657
-   feature: Add invalidate flag to logout by [@&#8203;Zertsov](https://togithub.com/Zertsov) in [vercel/turbo#7444
-   feat: terminal pane component by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7619
-   feat: add getter for selected task by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7614
-   chore(Turborepo): refactor client side of daemon-backed package discovery by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7644
-   fix(turborepo): Logout by [@&#8203;NicholasLYang](https://togithub.com/NicholasLYang) in [vercel/turbo#7667
-   feat: add scan subcommand by [@&#8203;arlyon](https://togithub.com/arlyon) in [vercel/turbo#6788
-   fix(Turborepo): Fix cookie directory by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7664
-   refactor(turborepo): Split up `Run` into `RunBuilder` and `Run` by [@&#8203;NicholasLYang](https://togithub.com/NicholasLYang) in [vercel/turbo#7681
-   chore: generalize log writer by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7678
-   chore: generalize cache terminal output by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7701
-   feat: add entire screen viewer to vt100 by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7699
-   fix(Turborepo): Handle directory moves in package discovery by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7700
-   chore(Turborepo): Handle unhandled error case in package discovery by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7703
-   feat: ensure PrefixedWriter is line buffered by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7728
-   chore(Turborepo): Consolidate Subscriber::watch and setup task by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7714
-   feat(Turborepo): add error handling to package discovery process by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7725
-   feat: enable new UI by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7733
-   fix: retry requests that fail due to timeout or request errors by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7745
-   feat: enable env var for preflight by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7754
-   chore: add ability to configure TUI via turbo.json by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7755
-   Add TURBO_CACHE_DIR env for `--cache-dir` flag by [@&#8203;weyert](https://togithub.com/weyert) in [vercel/turbo#6294
-   fix(ui): properly handle escape codes in persisted output by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7760
-   fix(ui): always start tasks by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7758
-   feat(Turborepo): handle invalid states in package watching by [@&#8203;gsoltis](https://togithub.com/gsoltis) in [vercel/turbo#7759
-   feat: add ability to configure tasks as interactive by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7767
-   feat: enable windows pty by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7780
-   chore(ui): add more info to table footer by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7788
-   chore: update turbo.json schema for interactive tasks by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7786
-   feat(pnpm): respect link-workspace-packages npmrc by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7791
-   feat: add ability to control UI via cli arg by [@&#8203;chris-olszewski](https://togithub.com/chris-olszewski) in [vercel/turbo#7793
-   feat: support apple git in scan diagnostic by [@&#8203;arlyon](https://togithub.com/arlyon) in [vercel/turbo#7740

#### New Contributors

-   [@&#8203;steveluscher](https://togithub.com/steveluscher) made their first contribution in [vercel/turbo#7669
-   [@&#8203;Dann1y](https://togithub.com/Dann1y) made their first contribution in [vercel/turbo#7702
-   [@&#8203;sooster910](https://togithub.com/sooster910) made their first contribution in [vercel/turbo#7683
-   [@&#8203;jamesbvaughan](https://togithub.com/jamesbvaughan) made their first contribution in [vercel/turbo#7781

**Full Changelog**: vercel/turbo@v1.12.5...v1.13.0

</details>

<details>
<summary>vercel/turbo (turbo)</summary>

### [`v1.13.0`](https://togithub.com/vercel/turbo/compare/v1.12.5...v1.13.0)

[Compare Source](https://togithub.com/vercel/turbo/compare/v1.12.5...v1.13.0)

</details>

<details>
<summary>Microsoft/TypeScript (typescript)</summary>

### [`v5.4.3`](https://togithub.com/microsoft/TypeScript/releases/tag/v5.4.3): TypeScript 5.4.3

[Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.4.2...v5.4.3)

For release notes, check out the [release announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/).

For the complete list of fixed issues, check out the

-   [fixed issues query for Typescript 5.4.0 (Beta)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+).
-   [fixed issues query for Typescript 5.4.1 (RC)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+).
-   [fixed issues query for Typescript 5.4.2 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+).
-   [fixed issues query for Typescript 5.4.3 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+).

Downloads are available on:

-   [NuGet package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday,before 4am on Thursday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/weareinreach/GLAAD).



PR-URL: #370
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants