Spot the bug in Uint8Array ID reading

from Typed arrays and ArrayBuffer
Node 24 intermediate 4 min 1 issue to find

Find why this helper can read the wrong message ID from a Uint8Array window.

JavaScript
function readMessageId(bytes) {
  if (bytes.byteLength < 4) throw new RangeError('Truncated ID');
  const view = new DataView(bytes.buffer);
  return view.getUint32(0, false);
}
Open in playground
Report an error