Fork me on GitHub
#clojurescript
<
2021-05-06
>
Jakob Durstberger10:05:17

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-himik10:05:00

The code itself looks fine to me.

Jakob Durstberger10:05:23

thanks for having a look. It is so odd 😕

p-himik11:05:07

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 Durstberger11:05:05

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-himik11:05:58

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

Jakob Durstberger11:05:23

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

emccue12:05:54

try doing #(.log js/console %)

emccue12:05:05

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

Jakob Durstberger13:05:24

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-himik13:05:52

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.

Empperi13:05:46

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

Empperi13:05:13

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

Empperi13:05:39

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

🎵 2