Fork me on GitHub
#datomic
<
2022-02-24
>
hkrish22:02:44

Hello Datomic Cloud experts, In dev environment, I am developing a Clojurescript/re-frame app, with a Datomic Cloud backend. The SPA access the local Jetty server, and the server code uses client-api to access Datomic Cloud, using Gateway (...

)
Two issues, I face all the time. 1. Startup time. Even from the REPL, the queries take a long time to get a response, first time. If I send consecutively other queries, the response is just fine. Sometimes, I even get Datomic Timeout error. 2. Probably because of the same issue, but I put it as a separate issue, we are not able to test the app with the CLJS browser app. What are the possible solutions available? Thanks for the suggestions. Also is there any change in the dev process needed? The CLJS app requires constant interaction with the server code and Datomic db. The CLJS is also under development. Can we use dev-local within a sever? The challenge I have then is with the REPL. The nREPL or Jetty put a lock on the data directory. Update: Now I see a transaction is failing due to CORS, inside the server. The log file shows this: [qtp670918934-35] INFO io.pedestal.http.cors - {:msg "cors response processing", :cors-headers {"Access-Control-Allow-Origin" "http://localhost:9875", "Access-Control-Allow-Credentials" "true", "Access-Control-Expose-Headers" "Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, X-Xss-Protection, X-Download-Options, X-Permitted-Cross-Domain-Policies, Content-Security-Policy"}, Many thanks in advance!

xceno09:02:28

If you don't have a specific reason for using a real datomic cloud instance for development, you should probably use dev-local. It's meant to be used for exactly this scenario. In my app I'm using several config files like config/dev.edn and config/prod.edn. Dev is configured to use dev-local and once deployed, the app uses the prod config to access datomic cloud. I'm not familiar with pedestal though, so I can't help you with that

hkrish09:02:11

Thank you. How do you run a local server and nREPL with dev-local?

xceno09:02:32

you run everything like you normally would and then just construct a datomic cloud but with dev-local config, like described here: https://docs.datomic.com/cloud/dev-local.html#using That's the critical piece:

(require '[datomic.client.api :as d])
(def client (d/client {:server-type :dev-local
                       :system "dev"}))

hkrish20:02:02

Thanks again. I just tried this. Looks great. Thanks for the suggestion. But I have another issue now. I use Cursive with IntelliJ, and access a nREPL server. But both a jetty server and an nREPL wouldn't run with dev-local. I haven't been able to figure it out. Any hint is welcome. Thanks again.

jacob.maine01:03:16

@U9RU257K3 it sounds like you’re running into problems constructing a classpath that includes the repl, jetty and dev-local. Classpath problems are very hard to debug without access to the code. My speculation is that when you start the nREPL, you aren’t using the deps.edn aliases that would pull in all 3 of those dependencies. I recommend that you reach out to the Cursive community (I’m not a Cursive user) to help you configure Cursive to start the repl correctly.

hkrish01:03:29

Thank you Jacob. I have included the dependencies as you suggested. Still I get this. Execution error (IOException) at http://datomic.core.io.file-channels/lock! (file_channels.clj:35). File <path to the storage-dir.............>/.lock is in use by another process. Like you suggested, it could be a classpath issue. Not able to figure it out. Will try to reach out to Cursive group support. Thanks for response. In the mean time, back to the client api with the cold start api issue!

jacob.maine07:03:26

@U9RU257K3 I’ve never seen that error. Do you have any other processes connected to the same dev-local :system? If so, stop them and try again. If not, you may want to try deleting that .lock file.