winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

Connections from `Queue.setConsumer` are not shown in console #7180

Open Chriscbr opened 1 month ago

Chriscbr commented 1 month ago

I tried this:

bring cloud;

class MyService {
  queue: cloud.Queue;
  bucket: cloud.Bucket;
  new() {
    this.queue = new cloud.Queue();
    this.bucket = new cloud.Bucket();

    this.queue.setConsumer(inflight () => {
      this.doSomething();
    });
  }

  inflight doSomething() {
    this.bucket.put("test.json", "test");
  }
}

new MyService();

This happened:

Screenshot 2024-09-30 at 11 21 13 AM

There's a missing arrow / connection between Queue and Bucket.

Connection data:

{
  "version": "connections-0.1",
  "connections": [
    {
      "source": "root/Default/MyService/Queue",
      "sourceOp": "push",
      "target": "root/Default/MyService/Queue/Consumer0",
      "targetOp": "invoke",
      "name": "consumer"
    },
    {
      "source": "root/Default/MyService",
      "sourceOp": "doSomething",
      "target": "root/Default/MyService/Bucket",
      "targetOp": "put",
      "name": "call"
    },
    {
      "source": "root/Default/MyService/Queue/Consumer0",
      "sourceOp": "invoke",
      "target": "root/Default/MyService",
      "targetOp": "doSomething",
      "name": "call"
    },
    {
      "source": "root/Default/MyService/Queue/Consumer0",
      "sourceOp": "invokeAsync",
      "target": "root/Default/MyService",
      "targetOp": "doSomething",
      "name": "call"
    }
  ]
}

I expected this:

Screenshot 2024-09-30 at 11 21 53 AM

Is there a workaround?

If I remove the doSomething() method (and inline the logic instead) the arrow appears correctly.

bring cloud;

class MyService {
  queue: cloud.Queue;
  bucket: cloud.Bucket;
  new() {
    this.queue = new cloud.Queue();
    this.bucket = new cloud.Bucket();

    this.queue.setConsumer(inflight () => {
      this.bucket.put("test.json", "test");
    });
  }
}

new MyService();

Connection data:

{
  "version": "connections-0.1",
  "connections": [
    {
      "source": "root/Default/MyService/Queue",
      "sourceOp": "push",
      "target": "root/Default/MyService/Queue/Consumer0",
      "targetOp": "invoke",
      "name": "consumer"
    },
    {
      "source": "root/Default/MyService/Queue/Consumer0",
      "sourceOp": "invoke",
      "target": "root/Default/MyService/Bucket",
      "targetOp": "put",
      "name": "call"
    },
    {
      "source": "root/Default/MyService/Queue/Consumer0",
      "sourceOp": "invokeAsync",
      "target": "root/Default/MyService/Bucket",
      "targetOp": "put",
      "name": "call"
    }
  ]
}

Anything else?

No response

Wing Version

0.85.12

Node.js Version

No response

Platform(s)

No response

Community Notes