`nuxt dev`: takeover prompt loses raw mode when terminal doesn't answer OSC 11

オープン 初心者向け
#1,685 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

まず withUserAttention と host.withTerminal を確認し、次に src/boot.ts の attachKeys と whenStdinReleased()、および制御引き継ぎプロンプトの経路と、それらの stdin の処理を比較します。OSC 11 に応答しないターミナルで再現し、タイムアウト後もプロンプトが raw モードを維持することを確認します。この状況で矢印キーによって選択項目が移動し、Enter で送信できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Version: @nuxt/cli 4.0.3, Nuxt 4.6.4, Node 24.16, macOS

Repro
  1. Start nuxt dev in a project and leave it running.
  2. In a terminal that does not reply to OSC 11 (ESC ] 11 ; ? BEL), run nuxt dev again in the same project.
  3. The "A Nuxt dev server is already running here" select prompt appears. Press ↑/↓.

Expected: the selection moves.

Actual: ~250ms after the prompt renders, stdin drops out of raw mode. Arrow keys echo as ^[[A, and Enter arrives as \n (readline names it enter, not return), so the prompt can't be answered. Only Ctrl-C gets out.

Cause

bootDevUI (src/boot.ts) paints the panel and calls queryBackground before the dev command reaches takeOverServer. listen() in src/dev/tui/background.ts captures wasRaw = false, sets raw mode, then in finish() (on reply or on the 250ms timeout) runs if (!wasRaw) stdin.setRawMode(false). By then clack's select has taken raw mode, so the restore turns it off underneath the prompt. attachKeys already waits for whenStdinReleased(); the takeover prompt (via withUserAttention) does not.

Verified by sampling the pty's termios flags: ICANON and ECHO switch back on 0.27s after the prompt appears. With NUXT_TERM_THEME=dark (no query sent), raw mode holds.

Suggested fix

Have withUserAttention / host.withTerminal await whenStdinReleased() before running the prompt, the same way attachKeys does. Alternatively, finish() could skip the raw-mode restore if stdin's raw state changed while the query was pending.

Workaround

export NUXT_TERM_THEME=dark (or light).

主要言語
TypeScript
スター
402
フォーク
125
平均マージ
2日 9時間
マージ済み PR(30日)
37

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nuxt/cli のほかの issue

nuxt/cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。