Skip to content

feat: add support for browser streaming #581

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

Closed
wants to merge 102 commits into from

Conversation

AllanZhengYP
Copy link
Contributor

Per #102 browser streaming as removed from preview because ReadableStream support in browsers was not ideal back then. Now since most of the browser vendors support ReadableStream, we can enable the feature.

Previously, the fetch-http-handler returns a promise of blob for body, even when we expect the body to be streaming sometimes(e.g. S3 GetObject). After these change, we can return a ReadableStream for streaming response in browser. This would avoid loading all the resposne body data in the brwoser memory.

reference:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

AllanZhengYP and others added 30 commits September 19, 2019 14:52
* chore: add http request type guard for middlewares

header default middleware
expect continue middleare

* chore: add http request type guard for apply body checksum middlewares

* chore: only build and test demo smithy client

* feat: add isInstance to httpResponse

* chore: update rds data model

* chore: update to ts3.7; update rds model#3

* chore: update tsconfig to genenerte types only once

* chore: update gitignore

* chore: parse body with streamCollector

* chore: add error deserialization

* chore: stub Field union

* fix: fix middleware-header-default test

* fix: fix retry-middleware unit test
* feat: remove 'apply' entry from configuration definition

'apply' was used to adjust middleware stack and resolved configuration.
It is not relative as we are moving to conposition configuration, and
middleware stack should not be altered by configurations.
Address: aws#94

* feat: complete PoC composable configuration

* feat: change config resolver to multiple client config components

* feat: rename stack finalize step to finalizeRequest

* feat: add use() to smithy client to inject middleware

* fix: rename resolvedruntime configuration

* fix: remove exported reviouslyResolved interface

* feat: add metadatabearer to shapes

* feat: parse derializing utils as parameters

* use config interface as middleware parameter
* use smithy command as super class of all commands so we can support use() in commands

* feat: parse serialize(deserialize) util functions from client config

* Serializers/Deserializers should take utils functions from client config
first, if not available then fallback to generated dependencies. This
allows configuring the runtime dependencies manually from client config when
runtime-specific bundlers' decision is not accountable

* feat: add metadata deserializer

* docs: add documentation for config properties

* feat: add defaultUserAgen config

* feat: move some config components to middleware folder

* signing middleware
* retry middleware; Also update retry config interface by introducing RetryStrategy class

* feat: add input type proxy for better intellisense

* docs: add config doc block for retry config

* feat: add a user agent middleware to support custom useragent
…#389)

* feat: add RetryStrategy class and change retryMiddleware interface
* feat: remove generated SerDe runtime dependencies

Instead, use the runtime-specific utils specified in client config

* fix: change plugin interface to callback functions mutating the stack
* feat: support pluggable runtime config

* export runtimeConfig.runtime.ts to manually set the client to be compatible with specific runtime
* get rid of rollup, instead using browser property to swap runtime config
* add endpoint to the serializer utilities and insert it when building a request

* chore: set prettier-vscode as default formatter
* fix: remove duplicated declaration of endpoints

* fix: rename serializerUtils to serializerContext
* feat: combine serde types, cleanup unused imports

* feat: update model location

* feat: change Injectable to Pluggable
* feat: remove rest-json protocol class

* feat: rename handler to RequestHandler; Consolidate types
mtdowling and others added 20 commits December 17, 2019 14:50
feat: name package

feat: migrate and apply middleware

feat: remove $ input options

feat: remove preformedBucket option
* fix: add BucketEndpoint config plugin

* fix: package exports
…ddleware (aws#574)

* fix: use host name from request instead of endpont provider

* fix: assure bucketEndpointMw applies before hostHeaderMw
@AllanZhengYP AllanZhengYP added the smithy-codegen Changes regarding supporting smithy model. Will be merged to smithy-codegen branch label Dec 27, 2019
@AllanZhengYP AllanZhengYP requested a review from trivikr December 27, 2019 01:38
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Member

@trivikr trivikr left a comment

Choose a reason for hiding this comment

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

There are some concerns about arrayBuffer not supported in Mobile browsers (Chrome/Firefox), and we'll handle them today.

): Promise<Uint8Array> => {
return new Response(stream)
.arrayBuffer()
.then(arrayBuffer => new Uint8Array(arrayBuffer));
Copy link
Member

Choose a reason for hiding this comment

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

add .catch() block here to throw for abort/error

@AllanZhengYP
Copy link
Contributor Author

The MDN data over arrayBuffer is inaccurate. According to chromiume feature table, Response.arrayBuffer() is supported as late as version 76, but I don't exactly which version it's added. Reference: https://chromestatus.com/features/6206980857266176:

Right now, developers can read a blob with a nicely promisified and/or streamified API by do something like: new Response(my_blob).body .arrayBuffer(), .text() etc The Response wrapping trick feels like a hack, and especially as long as FileReader exists, isn't very discoverable.

@lock
Copy link

lock bot commented Jan 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
smithy-codegen Changes regarding supporting smithy model. Will be merged to smithy-codegen branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants