streams: DelimiterStream leaves delimiter bytes in the output when the delimiter spans more than two chunks
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- deno, typescript
調査の方向性
DelimiterStreamの#handle()メソッドと、バッファリングされたチャンクが存在し、delimitedChunkEnd < 0となるissue記載の分岐から始めてください。複数のチャンクにまたがる部分的な区切り文字がどのようにトリミングされるかを追い、その後、issueの再現例を使って関連するstreamsのテストを実行してください。複数のチャンクにまたがる区切り文字について、空のチャンクを含め、discardとprefixが期待される出力を生成すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With a multi-byte delimiter, DelimiterStream (discard and prefix) outputs part of the delimiter as data when a delimiter match starts two or more chunks before the chunk that completes it. An empty chunk in the middle of a two-byte delimiter is enough (["\r", "", "\n"] with "\r\n").
Steps to Reproduce
repro.ts:
import { DelimiterStream } from "jsr:@std/[email protected]/delimiter-stream";
const te = new TextEncoder(), td = new TextDecoder();
const run = async (
chunks: string[],
delim: string,
disposition: "discard" | "prefix" | "suffix" = "discard",
) => {
const out: string[] = [];
for await (
const c of ReadableStream.from(chunks.map((s) => te.encode(s)))
.pipeThrough(new DelimiterStream(te.encode(delim), { disposition }))
) {
out.push(td.decode(c));
}
return out;
};
console.log(await run(["xabcy"], "abc"));
console.log(await run(["xa", "b", "cy"], "abc"));
console.log(await run([..."one<END>two"], "<END>"));
console.log(await run(["\r", "", "\n"], "\r\n"));
console.log(await run(["xa", "b", "cy"], "abc", "prefix"));
deno run repro.ts
Expected behavior
[ "x", "y" ]
[ "x", "y" ]
[ "one", "two" ]
[ "", "" ]
[ "x", "abcy" ]
Actual behavior
[ "x", "y" ]
[ "xa", "y" ]
[ "one<EN", "two" ]
[ "\r", "" ]
[ "xa", "bcy" ]
In #handle(), the delimitedChunkEnd < 0 && bufs.length > 0 branch assumes the partial delimiter lies entirely in the last buffered chunk (last.byteLength + delimitedChunkEnd). When it spans several buffered chunks, that index goes negative and the earlier chunks are not trimmed.
Environment
- OS: Ubuntu Linux x86_64
- deno version: 2.9.8
- std version: @std/streams 1.2.0, also
mainat f834d02 (same output)
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 3.6k
- フォーク
- 713
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
denoland/std のほかの issue
-
`assertEquals` throws on structurally equal `Error` objects due to different stack trace対応中かも @powerman2026 が 1 日前に担当しました。 オープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
@std/encoding: decodeAscii85 corrupts delimited data ending in "<", decodeVarint32 reads past the end of the buffer対応中かも @helmipradita が 15 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
@std/yaml: stringify() with condenseFlow wraps already quoted keys in a second pair of quotes対応中かも @sebxt が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
@std/ini parse silently drops an entire section when the section name repeats対応中かも @Harsh23Kashyap が 35 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
cli: parseArgs() treats an empty flag value passed without "=" as a positional argument対応中かも @helmipradita が 23 日前に担当しました。 オープンbug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
denoland/std#7351 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vercel-labs/ui#1066 ·
メンテナーはふだん 1 日以内に返信
-
fix(factory-cockpit): display active agent/actor name instead of verbose step name in run card badgeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ranxianglei/billion-context#7597 ·
メンテナーはふだん 1 日以内に返信
-
documentation target:powerpoint
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
tomast1337/PdfLapas#602 ·
メンテナーはふだん 1 日以内に返信
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every run対応中かも @kc9ddi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TeraSky-OSS/backstage-plugins#228 ·