Skip to content

Commit 7939f39

Browse files
committed
fix: serialize input RPCs to preserve byte order (#3164)
ControllerInputCommand was fire-and-forget, letting wavesrv process concurrent calls on separate goroutines and reorder bytes before they reached the PTY. Under fast IME composition followed by ASCII input this produced visible corruption like "이 런문제" instead of "이런 문제" — the same user-visible symptom as #3164 even after the xterm-side IME fix earlier in this PR. Chain calls through a Promise queue so each RPC awaits the previous, preserving dispatch order all the way to the PTY.
1 parent 34aad10 commit 7939f39

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

frontend/app/view/term/term-model.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,16 @@ export class TermViewModel implements ViewModel {
506506
}
507507
}
508508

509+
// Serialize input RPCs to preserve order. Without this, fire-and-forget
510+
// calls can be processed concurrently on the backend and reorder bytes
511+
// (especially visible with fast IME composition followed by ASCII input).
512+
inputQueue: Promise<void> = Promise.resolve();
513+
509514
sendDataToController(data: string) {
510515
const b64data = stringToBase64(data);
511-
RpcApi.ControllerInputCommand(TabRpcClient, { blockid: this.blockId, inputdata64: b64data });
516+
this.inputQueue = this.inputQueue
517+
.then(() => RpcApi.ControllerInputCommand(TabRpcClient, { blockid: this.blockId, inputdata64: b64data }))
518+
.catch(() => {});
512519
}
513520

514521
setTermMode(mode: "term" | "vdom") {

0 commit comments

Comments
 (0)