Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Infinite recursion on nested types #412

Closed
FMenet opened this issue Apr 16, 2020 · 1 comment · Fixed by #415
Closed

Infinite recursion on nested types #412

FMenet opened this issue Apr 16, 2020 · 1 comment · Fixed by #415

Comments

@FMenet
Copy link
Contributor

FMenet commented Apr 16, 2020

1 - versions : tested on neo4j-graphql-js 2.13.0 and 2.11.5
2 - what happens : on these types of query (see below), an infinite recursion happens, with large memory allocation
3 - steps to reproduce :
make a double nested query such as this dummy :

 fragment Leaf on Objective {
 id
 name
 __typename
}

fragment Branch on Objective {
 ...Leaf
 subBranch {
 ...Leaf
 subBranch {
 ...Leaf
 subBranch {
 ...Leaf
 __typename
 }
 __typename
 }
 __typename
 }
 __typename
}

query getATree($id: ID) {
 
 objectives {
 id
 ...Branch
 __typename
 }
 
}

On debugging, one can see that an-ever-expanding array of Cypher Selections is created.
(breakpoint on selection.js:795 for example)

After a few seconds, the app crashes.

4 - Status.
Working on a fix as we speak, but I think I could use some help :)

@michaeldgraham
Copy link
Collaborator

Hey there, so I've been able to replicate this with the following schema:

type Query {
  objectives(id: ID): [Objective]
}

interface Objective {
  id: ID
  name: String
  subBranch: Branch @relation(name: "BRANCH_OF", direction: OUT)
}

type Leaf implements Objective {
  id: ID
  name: String
  subBranch: Branch @relation(name: "BRANCH_OF", direction: OUT)
}

type Branch implements Objective {
  id: ID
  name: String
  subBranch: Branch @relation(name: "BRANCH_OF", direction: OUT)
}

and this query (id argument removed):

fragment Leaf on Objective {
  id
  name
  __typename
}

fragment Branch on Objective {
  ...Leaf
  subBranch {
    ...Leaf
    subBranch {
      ...Leaf
      subBranch {
        ...Leaf
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}

query getATree {
  objectives {
    id
    ...Branch
    __typename
  }
}

This looks exactly like an issue I had during development which I thought had been fully resolved. It has to do with generated content persisting within an operation's resolveInfo when the same fragmented operation is run again. It's definitely no good, I'll check out the same suspect code that caused it before

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants