winglang / wing

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

--rootId option does nothing in `sim` #6598

Open MarkMcCulloh opened 3 weeks ago

MarkMcCulloh commented 3 weeks ago

I tried this:

log(nodeof(this).app.node.id);

Then run wing compile --rootId hello

This happened:

Outputs "root"

I expected this:

Outputs "hello"

Is there a workaround?

No response

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

eladb commented 3 weeks ago

P1

On Thu, May 30, 2024 at 1:13 PM Mark McCulloh @.***> wrote:

I tried this:

log(nodeof(this).app.node.id);

Then run wing compile --rootId hello This happened:

Outputs "root" I expected this:

Outputs "hello" Is there a workaround?

No response Anything else?

No response Wing Version

No response Node.js Version

No response Platform(s)

No response Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.

— Reply to this email directly, view it on GitHub https://github.com/winglang/wing/issues/6598, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESGDC7FVK4QNQ2D6WE4V3ZE4CW5AVCNFSM6AAAAABIQWYYRCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZDKMZZGI4TQMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

eladb commented 3 weeks ago

BTW, I think rootId does change the name of the root but that's not necessarily reflected in app.id.

tsuf239 commented 2 weeks ago

Elad is right, it seems like you can print the rootId by: log(util.tryEnv("WING_ROOT_ID") ?? "") is it good enough? or it has to be passed through nodeof(this).app.node.id ?

MarkMcCulloh commented 1 week ago

In checking this again, it does work as expected in the non-sim targets. While WING_ROOT_ID is always set correctly, I had run into issues with this inconsistency at the construct/node level. I don't remember the actual problem at this point, but it makes sense for the sim to behave the same imo

tsuf239 commented 1 week ago

it's because of this apparently, I'll take a look later to see if we can change it- https://github.com/winglang/wing/blob/main/libs/wingsdk/src/target-sim/app.ts#L93-L94