-
Notifications
You must be signed in to change notification settings - Fork 196
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
cloud.Service causes thread to hang #4086
Comments
Fixes #4086 ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Congrats! 🚀 This was released in Wing 0.29.7. |
@Chriscbr this feels wrong (at least in my mind). The intent was that onStart is asynchronous and never blocks. Maybe we need to change its name or document it better but as I see it onStart should kick off the start of the server and yield asynchronously. A |
@eladb OK, got it. Definitely sounds worth documenting.
right, if I understand your comment correctly, if I wanted to achieve the behavior in the example I gave, I'd have to move the |
Not sure exactly what's the use case behind the example, but generally speaking, busy-waiting is not a common pattern in node.js based programs. Perhaps some kind of an async interval is the right fit for something like this ( |
Say if you were trying to poll for tasks from an SQS queue from an ECS task container (you aren't a built-in AWS integration, so you are responsible for doing polling yourself). If I was implementing this, my initial hunch would be to write a busy loop of some kind, right?
But I think you're right that using |
A missing `await` in the simulator `start()` method resulted in resource becoming ready prematurely (fixes #4251). This reverts the change in #4086 which mistakingly assumed that `onStart` can block. Added a comment to the documentation of this handler. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
I tried this:
I wrote this Wing program:
and I ran
wing test main.w
This happened:
The test hangs indefinitely
I expected this:
I expected the test to pass. cloud.Service represents a long-running service, so it should be possible to have it run code continuously in the background.
Is there a workaround?
No response
Component
SDK
Wing Version
0.28.1
Node.js Version
18.14.1
Platform(s)
MacOS
Anything else?
Even though the simulator is single-threaded, this shouldn't cause an issue since the service's
onStart
code callsutil.sleep()
which gives the JavaScript runtime the chance switch to other tasks.See this passing test with
cloud.Function
:Community Notes
The text was updated successfully, but these errors were encountered: