-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When using result.next().await to iterate over query results that return multiple rows, the iteration terminates prematurely, returning fewer results than expected. Single-row queries work correctly.
Environment
- neo4rs version: 0.9.0-rc.9
- Neo4j version: 5.x (running in Kubernetes)
- Rust version: 1.81+
- OS: Linux (container)
Steps to Reproduce
- Create multiple FOLLOWS relationships in Neo4j:
CREATE (a:User {id: "user-1"})-[:FOLLOWS]->(b:User {id: "user-2"})
CREATE (a:User {id: "user-1"})-[:FOLLOWS]->(c:User {id: "user-3"})
CREATE (a:User {id: "user-1"})-[:FOLLOWS]->(d:User {id: "user-4"})
CREATE (a:User {id: "user-1"})-[:FOLLOWS]->(e:User {id: "user-5"})
CREATE (a:User {id: "user-1"})-[:FOLLOWS]->(f:User {id: "user-6"})- Query using neo4rs:
let cypher = r#"
MATCH (user:User {id: $user_id})-[:FOLLOWS]->(following:User)
RETURN following.id AS following_id
ORDER BY following.id
SKIP $offset
LIMIT $limit
"#;
let mut result = graph
.execute(
query(cypher)
.param("user_id", "user-1")
.param("offset", 0i64)
.param("limit", 50i64),
)
.await?;
let mut following = Vec::new();
while let Some(row) = result.next().await? {
if let Ok(id_str) = row.get::<String>("following_id") {
following.push(id_str);
}
}
println!("Expected: 5, Got: {}", following.len());Expected Behavior
The loop should iterate 5 times and return all 5 following IDs.
Actual Behavior
The loop only iterates 1 time and returns only 1 result, even though:
- The same query in
cypher-shellreturns all 5 results - A separate COUNT query returns
total_count = 5 has_moreis calculated astrue(indicating more data exists)
Additional Context
What works correctly:
- Single-row queries (e.g.,
RETURN count(r) > 0 AS is_following) work fine - The same data queried via PostgreSQL returns all 5 results
Possibly related:
- Issue Neo4j Server throwing IllegalState exception during PULL #236 describes a similar Bolt protocol state machine issue where
PULLmessages fail because the session transitions toREADYstate prematurely - This might be related to the
RowStreambuffer/fetch logic or Bolt protocol state synchronization
Workaround
We've switched to using PostgreSQL for list queries while keeping Neo4j for single-value lookups and graph traversals.
Code Reference
Our repository pattern:
pub struct GraphRepository {
graph: Arc<Graph>,
}
impl GraphRepository {
pub async fn new(uri: &str, user: &str, password: &str) -> Result<Self> {
let graph = Graph::new(uri, user, password)?;
Ok(Self { graph: Arc::new(graph) })
}
}The Graph is wrapped in Arc and shared across async tasks. Could this be related to connection pool state issues?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working