Skip to content

ds/start hangs indefinitely consuming a promesa.exec.csp/chan #43

@Ramblurr

Description

@Ramblurr

The start function hands indefinitely when a component returns a map containing a promesa channel.

Promesa channels act like seqs apparently?

To reproduce:

  1. Create a component that returns {:a-chan (sp/chan)} from its ::ds/start function. Where sp/chan is https://funcool.github.io/promesa/latest/promesa.exec.csp.html#var-chan
  2. Create another component that references the first one using a local-ref (with the goal of using :a-chan inside it)
  3. Start the donut system
  (require '[donut.system :as ds])
  (require '[promesa.exec.csp :as sp])
  (ds/start
   {::ds/defs {:group {:first {::ds/start (fn [_]
                                            {:a-chan (sp/chan)})}

                       :second {::ds/start  (fn [{::ds/keys [config]}]
                                              {:got config})
                                ::ds/config {:first [::ds/local-ref [:first]]}}}}})
;; Warning: evaling this will hang

Result: The eval of ds/start will never return, as it enters the sp/chan->seq function and blocks waiting for something to appear on the channel.

Image

It seems that donut is seqing inside the map returned by the first component:

(def ref-type (fn [v] (when (seqable? v) (first v))))

This triggers sp/chan->seq, which blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions