clockworklabs/SpacetimeDB · error

failed to serialize http response

Error message

failed to serialize http response

What it means

Error "failed to serialize http response" thrown in clockworklabs/SpacetimeDB.

Source

Thrown at crates/bindings/src/rt.rs:1214

    let timestamp = Timestamp::from_micros_since_unix_epoch(timestamp as i64);
    let mut ctx = HandlerContext::new(timestamp);

    let handlers = HTTP_HANDLERS.get().unwrap();
    let request = read_bytes_source_as::<spacetimedb_lib::http::Request>(request);
    // TODO(streaming-http): stop reading the full request body into guest memory once handlers
    // can consume the body incrementally from the host-provided byte source.
    let request_body = if request_body == BytesSource::INVALID {
        bytes::Bytes::new()
    } else {
        let mut buf = IterBuf::take();
        read_bytes_source_into(request_body, &mut buf);
        buf.clone().into()
    };
    let request = http::request_from_wire(request, request_body);

    let response = handlers[id](&mut ctx, request);
    let (response_meta, response_body_bytes) = http::response_into_wire(response);
    let bytes = bsatn::to_vec(&response_meta).expect("failed to serialize http response");
    write_to_sink(response_sink, &bytes);
    write_to_sink(response_body_sink, &response_body_bytes);

    0
}

/// Called by the host to execute an anonymous view.
///
/// The `args` is a `BytesSource`, registered on the host side,
/// which can be read with `bytes_source_read`.
/// The contents of the buffer are the BSATN-encoding of the arguments to the view.
/// In the case of empty arguments, `args` will be 0, that is, invalid.
///
/// The output of the view is written to a `BytesSink`,
/// registered on the host side, with `bytes_sink_write`.
///
/// Note, a previous version of the abi used a different return format for views.
/// We used to write the return rows of the view directly to the sink.

View on GitHub (pinned to 524b4487d9)

When it happens

Trigger: Thrown at crates/bindings/src/rt.rs:1214 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/9da662dae2d71010. Report an issue: GitHub.