-
Notifications
You must be signed in to change notification settings - Fork 181
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
missing UI connection from Api to Bucket #6458
Comments
We're missing information from the simulator. These are the connections listed: [
{
"source": "root/Default/Api",
"target": "root/Default/Api/OnRequestHandler0",
"name": "post()"
},
{
"source": "root/Default/$Closure1_0",
"sourceOp": "handle",
"target": "root/Default/Bucket",
"targetOp": "put",
"name": "put"
}
] So basically we're missing some connection from @Chriscbr any insights? |
I did a bit of digging. In theory there should be another connection getting generated, but there's a little architectural issue:
I feel like the best solution here would be to make inflights constructs again. It would also let us clean up this issue where token resolvers are globals, which seems like it might cause issues in the future. But I'm curious what y'all think @MarkMcCulloh @eladb |
Could the inflight host (e.g. OnRequestHandler) add the connection itself? It knows what connections the inflight has (lifts) so maybe it can link itself to them. |
note: It looks the issue of broken extension also applies whenever you create an inflight using the TypeScript framework: import { cloud, inflight, lift, main } from "@wingcloud/framework";
import assert from "node:assert";
main((root, test) => {
const bucket = new cloud.Bucket(root, "Bucket");
const fn = new cloud.Function(
root,
"Function",
lift({ bucket }).inflight(async (ctx) => {
ctx.bucket.put("key", "value");
return "hello, world";
})
);
test(
"fn returns hello",
lift({ fn }).inflight(async ({ fn }) => {
assert.equal(await fn.invoke(""), "hello, world");
})
);
}); With the same code in Wing it works: bring cloud;
let bucket = new cloud.Bucket();
let fn = new cloud.Function(inflight () => {
bucket.put("key", "value");
return "hello, world";
});
test "fn returns hello" {
assert(fn.invoke() == "hello, world");
}
I'd like to take you up on this suggestion. Putting it another way, we'd be making it the responsibility of the inflight host to register any connection data while it's lifting the inflight. It feels like a logical place to do the work. It would mean that a free-floating inflight closure (that doesn't get used anywhere) wouldn't emit any connection data, which also feels right. I imagine the logic can be included as part of the lifting stuff here: wing/libs/wingsdk/src/cloud/function.ts Lines 123 to 125 in 18cce73
|
Fixes #6458 Some UI connections were missing in the Wing Console because when generating information about different resource nodes, inflight closures created in Winglang were treated as resources while inflight closures created using the TypeScript framework were not. To fix this discrepancy, this PR changes how connections are generated so that all intermediate inflight closures are no longer modeled as nodes. Instead, inflight closures (both those created in Winglang and in TypeScript) are explored until resource-like nodes are reached. Taking this app as an example: ```js let b = new cloud.Bucket(); let listData = inflight () => { b.list(); }; new cloud.Function(inflight () => { listData(); b.put("hello.txt", "world"); }); ``` Previously the SDK generated this connection data: ```js { "source": "root/Default/$Closure1_0", "sourceOp": "handle", "target": "root/Default/Bucket", "targetOp": "list", "name": "list" }, { "source": "root/Default/$Closure2_0", "sourceOp": "handle", "target": "root/Default/Bucket", "targetOp": "put", "name": "put" }, { "source": "root/Default/$Closure2_0", "sourceOp": "handle", "target": "root/Default/$Closure1_0", "targetOp": "handle", "name": "handle" }, { "source": "root/Default/Function", "sourceOp": "invoke", "target": "root/Default/$Closure2_0", "targetOp": "handle", "name": "handle" }, { "source": "root/Default/Function", "sourceOp": "invokeAsync", "target": "root/Default/$Closure2_0", "targetOp": "handle", "name": "handle" } ``` Now it generates this connection data (note that all "closure" nodes are gone - we just emit relationships between real resources): ```js { "source": "root/Default/Function", "sourceOp": "invoke", "target": "root/Default/Bucket", "targetOp": "put", "name": "put" }, { "source": "root/Default/Function", "sourceOp": "invoke", "target": "root/Default/Bucket", "targetOp": "list", "name": "list" }, { "source": "root/Default/Function", "sourceOp": "invokeAsync", "target": "root/Default/Bucket", "targetOp": "put", "name": "put" }, { "source": "root/Default/Function", "sourceOp": "invokeAsync", "target": "root/Default/Bucket", "targetOp": "list", "name": "list" } ``` ## 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.73.52. |
I tried this:
This happened:
I expected this:
To see connection between api gateway to bucket
Is there a workaround?
No response
Anything else?
No response
Wing Version
0.73.41
Node.js Version
No response
Platform(s)
No response
Community Notes
The text was updated successfully, but these errors were encountered: