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

Run cloud.Function outside of NodeJS vm sandbox #4725

Closed
MarkMcCulloh opened this issue Oct 30, 2023 · 4 comments · Fixed by #5554
Closed

Run cloud.Function outside of NodeJS vm sandbox #4725

MarkMcCulloh opened this issue Oct 30, 2023 · 4 comments · Fixed by #5554
Assignees
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🎨 sdk SDK

Comments

@MarkMcCulloh
Copy link
Contributor

MarkMcCulloh commented Oct 30, 2023

Feature Spec

When invoking a cloud.Function in the simluator, an isolated worker/process is spawned to do the work. This should work/feel similar to simply running the inflight code in a new nodejs process.

Use Cases

Provides a more realistic experience of running JS like you might experience on serverless platforms.

Will fix bugs relating to using VM sandboxes like:

Implementation Notes

Depends on #4697

The two primary options are

  • Create an entirely new child process to invoke the cloud.Function by just running node with arguments
  • (ideal, imo) Use https://nodejs.org/api/worker_threads.html as a means to isolate work. While this does not give us process isolation, it should isolate everything else. We can then use SharedArrayBuffer to communicate with the simulator by default (very fast), falling back to HTTP otherwise.

Component

SDK

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.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
@MarkMcCulloh MarkMcCulloh added ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl labels Oct 30, 2023
@monadabot monadabot added this to Wing Oct 30, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Oct 30, 2023
@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Oct 31, 2023
@garysassano
Copy link
Collaborator

Maybe another option: WinterJS

@garysassano
Copy link
Collaborator

Could this possibly address the problem I'm currently facing with Function.invokeAsync()? I can't test this on the simulator because by the time the function finishes executing, the wing test has already printed the results and exited. Given that everything runs within the single-threaded Node.js Event Loop, it's quite challenging.

@MarkMcCulloh
Copy link
Contributor Author

Maybe another option: WinterJS

In the future I think we'd be interested in exploring different runtimes (and/or allowing easy choosing), but to start with we're focusing on maximizing nodejs compatibility.

Could this possibly address the problem I'm currently facing with Function.invokeAsync()?

Probably not, sounds more like a Promise is dangling somewhere.

@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.59.43.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🎨 sdk SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants