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 results in wrong namespace #757

Closed
panterarocks49 opened this issue May 28, 2022 · 1 comment
Closed

Async eval results in wrong namespace #757

panterarocks49 opened this issue May 28, 2022 · 1 comment

Comments

@panterarocks49
Copy link

version

{:git/url "https://github.com/babashka/sci"
  :sha "ff4db9056392f052f4809c06c68e2bef9e26da09"}

platform
Javascript, browser

problem
Evaluating two strings in parallel (with sci.async) with the same context results in evaluation in the wrong namespace and could not resolve symbol errors.

The output of the repro below
image

repro

(require '[sci.core :as sci])
(require '[sci.async :as scia])
(require '[promesa.core :as p])

(def ctx (sci/init {:namespaces    {'clojure.core {'require scia/require}}
                    :async-load-fn (fn [{:keys [libname ns]}]
                                     (prn libname ns)
                                     (p/resolved
                                      (case libname
                                        acme.foo {:source "(ns acme.foo) (defn the-fn [] :hello)"}
                                        acme.bar {:source "(ns acme.bar) (defn the-fn [] :bye)"})))}))

(scia/eval-string* ctx "(ns test (:require [acme.foo :as foo])) (foo/the-fn)")
(scia/eval-string* ctx "(require '[acme.bar :as bar]) (bar/the-fn)")

expected behavior
I would expect it to behave the same as executing one at a time
Like this

(p/let [res (scia/eval-string* ctx "(ns test (:require [acme.foo :as foo])) (foo/the-fn)")
        res (scia/eval-string* ctx "(require '[acme.bar :as bar]) (bar/the-fn)")])

The first eval should be in the test namespace and the second should be in the user namespace

Sponser

@borkdude
Copy link
Collaborator

Fixed with d315e98 but I'll leave this open until we have written tests for this.

borkdude added a commit that referenced this issue May 29, 2022
borkdude added a commit that referenced this issue May 29, 2022
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