You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
buffer: isUtf8 and isAscii accept detached TypedArray views #64503
It's not obvious this is a bug. In both cases, the detached ArrayBuffer just comes back as zero-length. These APIs handle zero-length just fine (e.g. isUtf8(new Uint8Array(0))).
I do see that the docs say "Throws if the input is a detached array buffer" but I kind of view that as a doc error rather than an implementation error.
We also only check the detached_ property in these two methods AFAICT, all other uses of ABVC in the Buffer API just treat detached buffers as zero-length, including other string-encoding operations like Buffer.prototype.toString(). I'm ±0 on whether we should be erroring with detached backing ArrayBuffers, but it should be consistent imo
Ok, the implementation behavior is a bit inconsistent. I would suggest that the final isUtf8(transferedArrayBuffer) should just return true, being treated as a zero-length.
Activity
jasnell commentedon Jul 14, 2026
It's not obvious this is a bug. In both cases, the detached
ArrayBufferjust comes back as zero-length. These APIs handle zero-length just fine (e.g.isUtf8(new Uint8Array(0))).I do see that the docs say "Throws if the
inputis a detached array buffer" but I kind of view that as a doc error rather than an implementation error.Archkon commentedon Jul 14, 2026
Renegade334 commentedon Jul 14, 2026
We also only check the
detached_property in these two methods AFAICT, all other uses of ABVC in the Buffer API just treat detached buffers as zero-length, including other string-encoding operations likeBuffer.prototype.toString(). I'm ±0 on whether we should be erroring with detached backing ArrayBuffers, but it should be consistent imoArchkon commentedon Jul 14, 2026
Archkon commentedon Jul 14, 2026
jasnell commentedon Jul 15, 2026
Ok, the implementation behavior is a bit inconsistent. I would suggest that the final
isUtf8(transferedArrayBuffer)should just returntrue, being treated as a zero-length.Archkon commentedon Jul 15, 2026
buffer: treat detached ArrayBuffers as empty
buffer: treat detached ArrayBuffers as empty
buffer: treat detached ArrayBuffers as empty
buffer: treat detached ArrayBuffers as empty