Skip to content

Bugfix/upstream stream io fix #11

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

Merged
merged 7 commits into from
Sep 24, 2020

Conversation

fcobia
Copy link
Contributor

@fcobia fcobia commented Aug 15, 2020

This PR would replace my previous PR. While running a Leaf based app, I noticed that the CSS and JavaScript files were not being served up properly. They were returning status code 200, but contained 0 bytes. I discovered that the FileMiddleware is using streaming for the files, but the conversion from Vapor Response to Lambda response did not handle this case.

I have fixed this, but I had to change the API a little because the fix requires the use of promises and event loops.

I spent a little time looking into doing some tests, but that requires creating a Lambda.Context object and all the APIs I could find for doing are marked internal and are therefore inaccessible. If you have any pointers into how I might do that, I would be happy to look into creating some test requests.

fcobia added 2 commits July 26, 2020 09:42
commit ba304a1
Author: Frank Cobia <frank_cobia@me.com>
Date:   Sat Aug 15 14:15:33 2020 -0400

    Ran swift format

commit 443f625
Author: Frank Cobia <frank_cobia@me.com>
Date:   Sat Aug 15 14:05:53 2020 -0400

    Make the cookies code more compact

commit 58f1d7b
Author: Frank Cobia <frank_cobia@me.com>
Date:   Sat Aug 15 13:46:34 2020 -0400

    Testing without the call to buffer

commit 14f6786
Author: Frank Cobia <frank_cobia@me.com>
Date:   Thu Aug 13 21:21:36 2020 -0400

    Removed debugging code

commit 5b6841b
Author: Frank Cobia <frank_cobia@me.com>
Date:   Wed Aug 12 22:15:31 2020 -0400

    Attempting to work with streams

commit e339fc9
Author: Frank Cobia <frank_cobia@me.com>
Date:   Wed Aug 12 02:02:37 2020 -0400

    Removed the streaming code for the response

commit 75a605b
Author: Frank Cobia <frank_cobia@me.com>
Date:   Wed Aug 12 00:54:49 2020 -0400

    Fixed a compiler error

commit 334b559
Author: Frank Cobia <frank_cobia@me.com>
Date:   Wed Aug 12 00:50:51 2020 -0400

    Collect stream body

commit e836aed
Author: Frank Cobia <frank_cobia@me.com>
Date:   Wed Aug 12 00:06:12 2020 -0400

    Check the response body for bytes

commit 4b3de95
Author: Frank Cobia <frank_cobia@me.com>
Date:   Tue Aug 11 23:45:31 2020 -0400

    More debugging code

commit 3fff709
Author: Frank Cobia <frank_cobia@me.com>
Date:   Tue Aug 11 23:32:17 2020 -0400

    Added some debugging code

commit 491867f
Merge: 4aa8155 9bb4790
Author: Frank Cobia <frank_cobia@me.com>
Date:   Tue Aug 11 22:20:35 2020 -0400

    Merge branch 'bugfix/PRChanges' into debugging

commit 9bb4790
Author: Frank Cobia <frank_cobia@me.com>
Date:   Tue Aug 11 22:20:15 2020 -0400

    Ran swiftformat

commit 7089d2f
Author: Frank Cobia <frank_cobia@me.com>
Date:   Tue Aug 11 22:11:28 2020 -0400

    Undo the cookie change

commit 4aa8155
Author: Frank Cobia <frank_cobia@me.com>
Date:   Tue Aug 11 19:24:41 2020 -0400

    Ran swiftformat

commit 78f6e19
Author: fcobia <frank_cobia@me.com>
Date:   Tue Aug 11 19:20:36 2020 -0400

    Update Sources/VaporAWSLambdaRuntime/APIGatewayV2.swift

    Co-authored-by: Fabian Fett <fabianfett@mac.com>

commit d2172d2
Author: Frank Cobia <frank_cobia@me.com>
Date:   Sat Aug 8 11:34:21 2020 -0400

    Attempting to fix query parameters

commit d7e2b9b
Author: Frank Cobia <frank_cobia@me.com>
Date:   Sun Jul 26 11:47:06 2020 -0400

    Attempting to fix the cookies
@codecov
Copy link

codecov bot commented Aug 15, 2020

Codecov Report

Merging #11 into main will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##            main     #11      +/-   ##
========================================
- Coverage   0.02%   0.02%   -0.01%     
========================================
  Files        509     531      +22     
  Lines      36361   39630    +3269     
========================================
  Hits           8       8              
- Misses     36353   39622    +3269     
Impacted Files Coverage Δ
Sources/VaporAWSLambdaRuntime/APIGateway.swift 0.00% <ø> (ø)
Sources/VaporAWSLambdaRuntime/APIGatewayV2.swift 0.00% <0.00%> (ø)
Sources/VaporAWSLambdaRuntime/LambdaServer.swift 0.00% <ø> (ø)
.build/checkouts/swift-nio/Sources/NIO/Heap.swift 0.00% <0.00%> (ø)
...build/checkouts/swift-nio/Sources/NIO/Socket.swift 0.00% <0.00%> (ø)
...build/checkouts/swift-nio/Sources/NIO/System.swift 0.00% <0.00%> (ø)
...uild/checkouts/swift-nio/Sources/NIO/Channel.swift 0.00% <0.00%> (ø)
...ild/checkouts/swift-nio/Sources/NIO/PipePair.swift 0.00% <0.00%> (ø)
...ld/checkouts/swift-nio/Sources/NIO/Bootstrap.swift 0.00% <0.00%> (ø)
...ld/checkouts/swift-nio/Sources/NIO/EventLoop.swift 0.00% <0.00%> (ø)
... and 89 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a35ef5...62acd6d. Read the comment docs.

@fabianfett
Copy link
Contributor

@fcobia Oh my god! I'm so sorry for not having reviewed this yet. I thought I had but apparently, I didn't. So Sorry.

Copy link
Contributor

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fcobia Thanks so much. This looks really good, I do have a few comments...
And once again, I'm so sorry for not looking at this earlier.

var headers = [String: [String]]()
static func from(response: Vapor.Response, in context: Lambda.Context) -> EventLoopFuture<APIGateway.V2.Response> {
// Create the promise
let promise = context.eventLoop.makePromise(of: APIGateway.V2.Response.self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we don't need to create a Promise here.

fcobia and others added 4 commits September 23, 2020 22:08
@fcobia
Copy link
Contributor Author

fcobia commented Sep 24, 2020

I am new to Swift NIO and Vapor, so I am just trying to find my way through it. I took your changes and I re-ran my website in AWS and it works.

@fcobia fcobia requested a review from fabianfett September 24, 2020 02:44
@fabianfett
Copy link
Contributor

@fcobia awesome. Do you want to run swiftformat .? If that's done, this is ready to merge. Thanks so much! This looks great!

@fcobia
Copy link
Contributor Author

fcobia commented Sep 24, 2020

Done

@fabianfett fabianfett merged commit 71bd3ec into vapor-community:main Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants