clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
Jakob Durstberger 2021-05-06T10:36:17.159600Z

I am trying using aws-sdk in cljs based on an official example but my promise never returns nor throws an error. Does someone know what I am doing wrong? js

const { DynamoDBClient, DescribeTableCommand } = require("@aws-sdk/client-dynamodb");
const dbclient = new DynamoDBClient({ region: "eu-west-2" });
  dbclient.send(new DescribeTableCommand({TableName: "table-name"}))
                .then((data) => console.log(data))
                .catch((error) => console.log(error));
cljs - never prints anything :(
(ns main
  (:require
   ["@aws-sdk/client-dynamodb" :refer [DynamoDBClient DescribeTableCommand]]))

(def db (DynamoDBClient. #js {:region "eu-west-2"}))

(-> (.send db (DescribeTableCommand. (clj->js {:TableName "table-name"})))
    (.then #(println %))
    (.catch #(println %)))

p-himik 2021-05-06T10:41:00.159800Z

The code itself looks fine to me.

Jakob Durstberger 2021-05-06T10:45:23.160Z

thanks for having a look. It is so odd 😕

p-himik 2021-05-06T11:00:07.160200Z

Are you doing it in the browser? If so, you can use the Network tab in the DevTools to see if the request is being sent at all. If you're on Node, you can use WireShark. Or maybe Node has something for that - no idea.

Jakob Durstberger 2021-05-06T11:02:05.160400Z

I am running node with shadow-cljs. I just found that the request actually succeeds but the then is never invoked. So I wrote an item to the db and I can see it in the aws console.

p-himik 2021-05-06T11:02:58.160700Z

You should be able to debug it. But I've never done it with Node so can't provide any pointers.

Jakob Durstberger 2021-05-06T11:04:23.161100Z

I’ll try copy the code into a browser project I have running. thanks for the tip

emccue 2021-05-06T12:09:54.161400Z

try doing #(.log js/console %)

emccue 2021-05-06T12:10:05.161600Z

thats the only difference in your code as far as i can see

Jakob Durstberger 2021-05-06T13:43:24.162200Z

Doesn’t seem to make a difference. I found out that it works fine when I compile it for node and run it with node index.js It just doesn’t print in the REPL

p-himik 2021-05-06T13:48:52.162400Z

Perhaps, your REPL doesn't print anything out and instead binds *out* to something that it later reads and outputs, and using promises intervenes with that. The output could still be in some other location though, not necessarily the REPL window itself.

Empperi 2021-05-06T13:50:46.163600Z

I'm facing a weird problem where I get goog.require could not find: goog.fs.blob which is coming from trustedresourceurl.js:9 which is requiring that file but there is no such file available. I've triple checked my transient dependencies but can't figure out what is going on here

Empperi 2021-05-06T13:51:13.164Z

I downgraded clojurescript but didn't help. Guess I have to try downgrading it further

Empperi 2021-05-06T13:56:39.164400Z

OK. Found it 😂 It was... Cache!

1🎵