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

feat: allow setting timeouts on uploads #1208

Merged
merged 2 commits into from Jun 11, 2020

Conversation

stephenplusplus
Copy link
Contributor

Fixes #1206

All of these should work:

await bucket.upload('file/path.txt', {timeout: 1});

await file.save('content', {timeout: 1});

file.createWriteStream({resumable: false, timeout: 1});

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 2, 2020
@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #1208 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1208   +/-   ##
=======================================
  Coverage   99.18%   99.18%           
=======================================
  Files          12       12           
  Lines       11471    11480    +9     
  Branches      528      529    +1     
=======================================
+ Hits        11377    11386    +9     
  Misses         94       94           
Impacted Files Coverage Δ
src/bucket.ts 99.52% <100.00%> (+<0.01%) ⬆️
src/file.ts 99.94% <100.00%> (+<0.01%) ⬆️

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 bcd77cd...4cf6e30. Read the comment docs.

@jkwlui
Copy link
Member

jkwlui commented Jun 2, 2020

Would it be better if we have the timeout option in a nested object? This separates the options that's related to the request versus those belonging to the API.

Something like:

await bucket.upload('file/path.txt', {reqOpts: {timeout: 1}});

@stephenplusplus
Copy link
Contributor Author

I do like the separation of that from a maintainer's perspective, but I think a lot of users just want a logical name for what they need, and "timeout" is about as intuitive as we can go. Otherwise, they'd have to learn and remember "reqOpts" (or whatever we might end up calling it). Some other sibling options exist such as "resumable", "encryptionKey", "userProject" which also affect the request.

If we had designed this in from the start, though, I would very much favor all of our methods accepting a "requestOptions" object that could have control over the request parameters (query string, headers, etc). We have the request interceptors system, which can cover that in most cases, but it's not as easy to use.

@stephenplusplus stephenplusplus marked this pull request as ready for review June 9, 2020 15:19
@stephenplusplus stephenplusplus requested a review from a team as a code owner June 9, 2020 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add operation timeout option
4 participants