Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async eval issues #748

Closed
awb99 opened this issue May 19, 2022 · 2 comments
Closed

async eval issues #748

awb99 opened this issue May 19, 2022 · 2 comments

Comments

@awb99
Copy link

awb99 commented May 19, 2022

version
master

problem
(ns example3 (:require [funny]))
(funny/joke)
(ns example4 (:require [funny :refer [joke]]))
(joke)
(ns example5 (:require [funny :as f]))
(f/joke)

all 3 examples work if I run them in a new sci context.

If I run all 3, then example4 fails with: "Could not resolve symbol: joke"
If I run just example3 + example4 then both work.

@borkdude
Copy link
Collaborator

@awb99 I need more information about how you are calling sci.async/eval-string* and what your SCI configuration is. Please provide a complete repro as a .cljs file that I can run to see the problem, e.g. as given here https://github.com/babashka/sci/blob/master/doc/async.md#lazy-loading-a-namespace.

@borkdude
Copy link
Collaborator

borkdude commented May 20, 2022

Ah, I managed to produce it like this:

(deftest async-eval-load-clojure-ns2-test
  (async done
         (p/let [sci-ns (sci/create-ns 'my.lazy-ns)
                 lazy-ns {'my-lazy-fn (sci/copy-var my-lazy-loaded-fn sci-ns)}
                 ctx (sci/init {:async-load-fn
                                (fn [{:keys [libname opts ctx ns]}]
                                  (js/Promise.resolve
                                   (sci/add-namespace! ctx libname lazy-ns)
                                   {}))})
                 code "

(ns foo1 (:require [my.lazy-ns]))
(my.lazy-ns/my-lazy-fn)

(ns foo2 (:require [my.lazy-ns :refer [my-lazy-fn]]))
(my-lazy-fn)
"
                 res (scia/eval-string* ctx code)]
           (is (= :hello res))
           (done))))

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

No branches or pull requests

2 participants