microsoft/typescript-go · critical · Error

Expected binary data (0xc4-0xc6), received: 0x${marker.toStr

Error message

Expected binary data (0xc4-0xc6), received: 0x${marker.toString(16)}

What it means

While reading the name or payload field, the parser expected a MessagePack bin marker (0xc4 bin8, 0xc5 bin16, 0xc6 bin32) but found another byte. The framing is misaligned or the peer encoded strings instead of raw bytes.

Source

Thrown at _packages/native-preview/src/api/syncChannel.ts:488

     * Read a MessagePack bin field.
     */
    private readBin(): Buffer {
        const marker = this.readByte();
        let size: number;
        switch (marker) {
            case MSGPACK_BIN8:
                size = this.readByte();
                break;
            case MSGPACK_BIN16:
                this.readExactInto(this.headerBuf, 2);
                size = (this.headerBuf[0] << 8) | this.headerBuf[1];
                break;
            case MSGPACK_BIN32:
                this.readExactInto(this.headerBuf, 4);
                size = this.headerBuf.readUInt32BE(0);
                break;
            default:
                throw new Error(
                    `Expected binary data (0xc4-0xc6), received: 0x${marker.toString(16)}`,
                );
        }
        if (size === 0) return EMPTY_BUF;
        return this.readExact(size);
    }

    // ── Low-level synchronous I/O ───────────────────────────────────

    /** Build an EOF error with the child's exit code/signal if available. */
    private eofError(): Error {
        const code = this.child.exitCode;
        const signal = this.child.signalCode;
        const detail = signal ? `killed by signal ${signal}` : code !== null ? `exited with code ${code}` : "unknown reason";
        return new Error(`Unexpected EOF while reading from child process (${detail})`);
    }

    /** Read a single byte from the buffered read-ahead. */

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Verify the peer writes bin8/bin16/bin32 for name and payload fields
  2. Remove any non-protocol stdout writes from the child
  3. Restart the channel after a corruption — alignment is unrecoverable
  4. Match package and child binary versions
Defensive patterns

Strategy: fallback

Try / catch

try { /* channel request */ } catch (e) { if (/Expected binary data/.test(e.message)) { /* framing lost: restart the channel session */ } throw e; }

Prevention

When it happens

Trigger: Desynchronized stream (same root cause as errors 83/84), or a child/hand-written peer that encodes the name/payload with str markers (0xa*/0xd*) instead of bin markers.

Common situations: Custom MessagePack encoders using 'str' for names; stdout pollution from the child; partial frame followed by EOF-ish garbage after a crash.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/ca140223fbce001c. Report an issue: GitHub.