neo4j-labs/neo4rs

0.7.0-rc.2 issue: "invalid utf-8 sequence of 1 bytes from index 34"

elimirks opened this issue · 3 comments

Version: 0.7.0-rc.2

I'm getting this error for a cypher query returning a lot of rows:

unexpected response for PULL: Err(DeserializationError(Other("invalid utf-8 sequence of 1 bytes from index 34")))

Seems to stem from line 81 in stream.rs.

    async fn read_chunk(&mut self, chunk_size: usize, buf: &mut BytesMut) -> Result<()> {
        let pos = buf.len();
        buf.resize(pos + chunk_size, 0);
        self.stream.read_exact(&mut buf[pos..]).await?;
        return Ok(());

        // This is an unsafe variant of doing the following
        // but skips the zero-initialization of the buffer
        //
        //     let pos = bytes.len();
        //     bytes.resize(pos + chunk_size, 0);
        //     self.stream.read_exact(&mut bytes[pos..]).await?;
        //
        // Alternatively, this an unsafe variant of the following except
        // it does read extactly `chunk_size` bytes and not maybe more
        //
        //     bytes.reserve(chunk_size);
        //     self.stream.read_buf(&mut bytes).await?;

Seems the unsafe version of this code is breaking something, doing this (as the comment suggested is safe) works fine

PR submitted: #151

Ive written a couple of tests returning several thousand elements in an array result, and also returning map, this seems to fix all of the problems experienced in #149