Streaming TextDecoder drops U+FEFF at the start of a chunk that follows an ASCII-only chunk
Maintainers usually reply within 1 day
@oliarmak-web is already working on this.
Since Nov 8, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp, javascript
Research direction
Start in src/workerd/api/encoding.c++ at IcuDecoder::decode and trace the UTF-8 ASCII fast path and bomSeen handling. Reproduce the reported outputs with the supplied worker.js and config.capnp using npx workerd serve, then compare streaming behavior with the Encoding Standard. Done when the later U+FEFF is preserved after an ASCII-only chunk and regression coverage exercises both ASCII and non-ASCII first chunks.
Written by the indexing model from the issue text.
Description
A streaming UTF-8 TextDecoder (and so TextDecoderStream) strips EF BB BF at the start of a later chunk as if it were a BOM, when every earlier chunk was ASCII. After a non-ASCII first chunk the same bytes are kept as U+FEFF, which is the expected result.
worker.js:
export default {
async fetch() {
const out = [];
const d = new TextDecoder();
out.push(JSON.stringify(d.decode(new Uint8Array([0x41]), { stream: true })));
out.push(JSON.stringify(d.decode(new Uint8Array([0xEF, 0xBB, 0xBF, 0x42]))));
const e = new TextDecoder();
out.push(JSON.stringify(e.decode(new Uint8Array([0xC3, 0xA9]), { stream: true })));
out.push(JSON.stringify(e.decode(new Uint8Array([0xEF, 0xBB, 0xBF, 0x42]))));
return new Response(out.join('\n') + '\n');
}
};
config.capnp:
using Workerd = import "/workerd/workerd.capnp";
const config :Workerd.Config = (
services = [(name = "main", worker = .worker)],
sockets = [(name = "http", address = "127.0.0.1:18787", http = (), service = "main")],
);
const worker :Workerd.Worker = (
modules = [(name = "worker.js", esModule = embed "worker.js")],
compatibilityDate = "2026-11-01",
);
npx workerd serve config.capnp and curl http://127.0.0.1:18787/
Actual:
"A"
"B"
"é"
"\ufeffB"
(JSON.stringify prints U+FEFF literally; it is written as \ufeff here)
Expected: the second line is also "\ufeffB", as in Node.js, Bun and browsers. Per https://encoding.spec.whatwg.org/#concept-td-serialize, BOM seen is set after the first code point, ASCII or not.
Tested with workerd 1.20261107.1 from npm (workerd 2026-11-07), Linux x64. The code is unchanged on main bf15531.
In IcuDecoder::decode (src/workerd/api/encoding.c++), the UTF-8 ASCII fast path returns without setting bomSeen = true, so the first non-ASCII chunk that reaches the ICU path still strips a leading U+FEFF.
Credit: https://ucsbplse.github.io/
- Dominant language
- C++
- Stars
- 9.3k
- Forks
- 845
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 558
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workerd
-
Build fails on macOS 27: dyld refuses stripped Rust proc-macros (mis-aligned LINKEDIT string pool)Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
cloudflare/workerd#8963 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cloudflare/workerd#8807 ·
Maintainers usually reply within 1 day
-
D1 export: `quote()` in d1.js turns a literal `\n` into a newline when the value also has a real newlinePossibly taken @Jeremiah-D claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
cloudflare/workerd#8678 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workerd#8575 ·
Maintainers usually reply within 1 day
-
fix(types): ForwardableEmailMessage omits the documented canBeForwarded propertyPossibly taken @itsrayeedscodespace claimed this 19 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workerd#8290 ·
Maintainers usually reply within 1 day
All issues in cloudflare/workerd
Similar issues
-
Android Bug Core Drape
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
organicmaps/organicmaps#14449 ·
Maintainers usually reply within 1 day
-
comp-codecs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ClickHouse/ClickHouse#135159 ·
Maintainers usually reply within 1 day
-
difficulty:easy func:python os:windows prio:high type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NatronGitHub/Natron#2029 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ardazishvili/Sota#114 ·
Maintainers usually reply within 1 day
-
`Rect::containsPoint` is not `const`, so a `const Rect` cannot be asked whether it holds a pointOpenNeeds: Triage :mag:
Difficulty 1/5 Under an hour Newbie friendliness 82/100
react/react-native#60349 ·
Maintainers usually reply within 1 day