Skip to content

Instantly share code, notes, and snippets.

@cigitia
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cigitia/c1f1fc48ebc041c979c5 to your computer and use it in GitHub Desktop.
Save cigitia/c1f1fc48ebc041c979c5 to your computer and use it in GitHub Desktop.
Infinite loop when using pull API on circular component reference (DataScript 0.9.0)
(ns demo.main
(:require [datascript :as ds]))
(def schema
{:x/component {:db/valueType :db.type/ref ; Required to demonstrate bug.
:db/isComponent true ; Required to demonstrate bug.
}})
(def conn
(ds/create-conn schema))
(ds/transact! conn
[{:db/id 1
:x/component {:db/id 1
:c/attribute "bar"}}])
(enable-console-print!)
(println "Point A")
; The circular reference from 1 to 1 causes an infinite loop when coupled with another bug
; when using the Push API on entity 1.
; Uncomment line below to induce freeze.
#_(prn (ds/pull @conn '[*] 1))
(println "Point B")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment