oven-sh/bun · error · bun_install::Error

UnknownMessageType

Error message

UnknownMessageType

What it means

The security scanner's IPC response JSON parsed correctly and had a string `type` field, but the value was neither "error" nor "result" — the only two message types Bun's protocol accepts (security_scanner.rs:1685-1690). This almost always indicates a scanner implementation bug or a protocol mismatch.

Source

Thrown at src/install/error.rs:117

    #[error("MissingIPCType")]
    MissingIPCType,
    #[error("InvalidIPCType")]
    InvalidIPCType,
    #[error("MissingErrorCode")]
    MissingErrorCode,
    #[error("InvalidErrorCode")]
    InvalidErrorCode,
    #[error("UnknownErrorCode")]
    UnknownErrorCode,
    #[error("SecurityScannerNotFound")]
    SecurityScannerNotFound,
    #[error("SecurityScannerNotInDependencies")]
    SecurityScannerNotInDependencies,
    #[error("InvalidScannerVersion")]
    InvalidScannerVersion,
    #[error("ScannerFailed")]
    ScannerFailed,
    #[error("UnknownMessageType")]
    UnknownMessageType,
    #[error("MissingAdvisoriesField")]
    MissingAdvisoriesField,
    #[error("SecurityScannerFailed")]
    SecurityScannerFailed,
    #[error("SecurityScannerTerminated")]
    SecurityScannerTerminated,
    #[error("InvalidAdvisoriesFormat")]
    InvalidAdvisoriesFormat,
    #[error("InvalidAdvisoryFormat")]
    InvalidAdvisoryFormat,
    #[error("MissingPackageField")]
    MissingPackageField,
    #[error("InvalidPackageField")]
    InvalidPackageField,
    #[error("EmptyPackageField")]
    EmptyPackageField,
    #[error("InvalidDescriptionField")]

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. In your scanner, emit exactly {"type":"result","advisories":[...]} on success and {"type":"error","code":...,"message":...} on failure
  2. Check the printed 'Unknown security scanner message type: <t>' value for typos in your scanner's writer
  3. Upgrade Bun — a newer release may understand the message type your scanner sends
  4. Ensure the scanner writes one complete JSON document and nothing else to the IPC pipe

Example fix

// before (scanner process IPC writer)
process.stdout.write(JSON.stringify({ type: "results", advisories }));

// after
process.stdout.write(JSON.stringify({ type: "result", advisories }));
Defensive patterns

Strategy: validation

Validate before calling

// in your scanner, assert the message shape before writing to IPC
function send(msg) {
  if (msg.type !== "error" && msg.type !== "result") throw new Error("bad IPC type: " + msg.type);
  process.stdout.write(JSON.stringify(msg));
}

Type guard

const isIPCMessage = (m) => m != null && (m.type === "error" || m.type === "result");

Prevention

When it happens

Trigger: A custom scanner writes a JSON object to IPC with e.g. "type":"results" (typo), "type":"scan-result", or emits a progress/log message type Bun does not understand. Any type string outside the exact set {"error", "result"} triggers it.

Common situations: Writing your own security scanner and guessing the protocol; a scanner version that added new message types (telemetry, progress) that this Bun version does not support; trailing garbage concatenated into the IPC stream being parsed as a second message.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/6d6bd25633a1f997. Report an issue: GitHub.