Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many functions of util should not be listed in preflight #6077

Open
meirdev opened this issue Mar 27, 2024 · 5 comments
Open

Many functions of util should not be listed in preflight #6077

meirdev opened this issue Mar 27, 2024 · 5 comments
Assignees
Labels
🐛 bug Something isn't working good first issue Good for newcomers 🎨 sdk SDK

Comments

@meirdev
Copy link
Contributor

meirdev commented Mar 27, 2024

I tried this:

bring util;

class Foo {
  new() {
    util.shell("sleep 1 && echo Hello > ../file.txt");

    let output = util.shell("cat ../file.txt", throw: true);
    log("{output}");
  }
}

new Foo();

This happened:

An error has occurred:
Failed to compile.

Error: Error executing command "cat ../file.txt". Exited with error: cat: ../file.txt: No such file or directory

I expected this:

No response

Is there a workaround?

No response

Anything else?

Because async functions are called normally (without await) they continue to run in the background and the following lines of code are called.

I think in this case it is better to hide async functions from a preflight block.

Wing Version

0.62.3

Node.js Version

v20.11.0

Platform(s)

MacOS

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.
@meirdev meirdev added the 🐛 bug Something isn't working label Mar 27, 2024
@monadabot monadabot added this to Wing Mar 27, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Mar 27, 2024
@Chriscbr
Copy link
Contributor

Ideally it would be nice to support these util functions in preflight as well - we just need to have separate preflight and inflight implementations of each relevant method. But flagging them as inflight-only for now sounds like a good solution to prevent the awkward error.

@Chriscbr Chriscbr added the 🎨 sdk SDK label Mar 27, 2024
@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Mar 28, 2024
@staycoolcall911 staycoolcall911 added the good first issue Good for newcomers label Mar 28, 2024
@staycoolcall911
Copy link
Contributor

Seems quite trivial to just define shell and the other async functions to run inflight in https://github.com/winglang/wing/blob/main/libs/wingsdk/src/util/util.ts

@revitalbarletz revitalbarletz self-assigned this Apr 15, 2024
@revitalbarletz
Copy link

Gowtham Kasi will take a look.

@garysassano
Copy link
Collaborator

This should actually be fixed by #5425 once it gets merged.

@revitalbarletz
Copy link

#5425 is fixed - @Chriscbr can we close this one as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working good first issue Good for newcomers 🎨 sdk SDK
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

5 participants