-
Notifications
You must be signed in to change notification settings - Fork 598
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
Emit errors from upstream on file upload #426
Conversation
@@ -528,6 +528,44 @@ describe('File', function() { | |||
writable.write('data'); | |||
}); | |||
|
|||
it('should re-emit errors', function(done) { | |||
var error = new Error('Error.'); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I believe handleError doesn't need to end the stream. Errors are emitted back to the stream that was passed into ... streams of tears. |
@@ -1056,7 +1060,6 @@ File.prototype.startResumableUpload_ = function(stream, metadata) { | |||
} | |||
|
|||
stream.emit('error', err); | |||
stream.end(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
PTAL 😄 |
Emit errors from upstream on file upload
👍 |
Is it possible that handleError() being called twice? i.e. one error event and one complete event with error come back to back? |
It was that the stream was being closed too many times. I believe we have addressed this issue fully. If you want to test against master, that would be wonderful! |
I wonder in real network scenario (not just the test mock environment), it is possible that there will be one error event and one complete event+error being emitted back to back with error code all equals to 404 or 499-600. If it happens, the handleError() will be called twice and startUpload() resumeUpload() will be called twice. |
The write stream will either emit an error or complete, it can't do both. Regardless, somewhat related, we should aim to "once-ify" our user provided callbacks. |
@teddybearz I can't help but feel I'm missing your point. If I am, thanks for your patience. |
BTW, is there a mock environment I can use to test my code that uses this library? So I can simulate bad-upload/bad-download/network-connection-reset those kinds of error cases programmatically? I am tired of pulling cable now 😄 |
@teddybearz You might have some luck trying out https://github.com/tylertreat/Comcast 😄 |
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/b742586e-df31-4aac-8092-78288e9ea8e7/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 325949033 Source-Link: googleapis/googleapis@94006b3
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/dfbad313-7afb-4cf6-b229-0476fcc2130c/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@57c23fa
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/dfbad313-7afb-4cf6-b229-0476fcc2130c/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@57c23fa
…es (#426) PiperOrigin-RevId: 317130948 Source-Author: Google APIs <noreply@google.com> Source-Date: Thu Jun 18 10:28:49 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: eb37e688331443969eed9b969531751154a956d5 Source-Link: googleapis/googleapis@eb37e68
Source-Author: Benjamin E. Coe <bencoe@google.com> Source-Date: Wed Aug 12 12:12:29 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 5747555f7620113d9a2078a48f4c047a99d31b3e Source-Link: googleapis/synthtool@5747555
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/6097b27f-11d0-4351-8f36-1ff5504fc384/targets - [ ] To automatically regenerate this PR, check this box.
🤖 I have created a release \*beep\* \*boop\* --- ## [2.2.0](https://www.github.com/googleapis/nodejs-iot/compare/v2.1.3...v2.2.0) (2021-01-09) ### Features * adds style enumeration ([#426](https://www.github.com/googleapis/nodejs-iot/issues/426)) ([4daeff4](https://www.github.com/googleapis/nodejs-iot/commit/4daeff47d5cfc5fd826705f4da5b8dbed1784e44)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Update npm scripts: add clean, prelint, prefix; make sure that lint and fix are set properly. Use post-process feature of synthtool.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [linkinator](https://github.com/JustinBeckwith/linkinator) | [`^2.0.0` -> `^4.0.0`](https://renovatebot.com/diffs/npm/linkinator/2.16.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/compatibility-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/confidence-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>JustinBeckwith/linkinator</summary> ### [`v4.0.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v4.0.0) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.1.0...v4.0.0) ##### Features - create new release with notes ([#​508](https://github.com/JustinBeckwith/linkinator/issues/508)) ([2cab633](https://github.com/JustinBeckwith/linkinator/commit/2cab633c9659eb10794a4bac06f8b0acdc3e2c0c)) ##### BREAKING CHANGES - The commits in [#​507](https://github.com/JustinBeckwith/linkinator/issues/507) and [#​506](https://github.com/JustinBeckwith/linkinator/issues/506) both had breaking changes. They included dropping support for Node.js 12.x and updating the CSV export to be streaming, and to use a new way of writing the CSV file. This is an empty to commit using the `BREAKING CHANGE` format in the commit message to ensure a release is triggered. ### [`v3.1.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.1.0) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.6...v3.1.0) ##### Features - allow --skip to be defined multiple times ([#​399](https://github.com/JustinBeckwith/linkinator/issues/399)) ([5ca5a46](https://github.com/JustinBeckwith/linkinator/commit/5ca5a461508e688de12e5ae6b4cfb6565f832ebf)) ### [`v3.0.6`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.6) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.5...v3.0.6) ##### Bug Fixes - **deps:** upgrade node-glob to v8 ([#​397](https://github.com/JustinBeckwith/linkinator/issues/397)) ([d334dc6](https://github.com/JustinBeckwith/linkinator/commit/d334dc6734cd7c2b73d7ed3dea0550a6c3072ad5)) ### [`v3.0.5`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.5) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.4...v3.0.5) ##### Bug Fixes - **deps:** upgrade to htmlparser2 v8.0.1 ([#​396](https://github.com/JustinBeckwith/linkinator/issues/396)) ([ba3b9a8](https://github.com/JustinBeckwith/linkinator/commit/ba3b9a8a9b19d39af6ed91790135e833b80c1eb6)) ### [`v3.0.4`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.4) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.3...v3.0.4) ##### Bug Fixes - **deps:** update dependency gaxios to v5 ([#​391](https://github.com/JustinBeckwith/linkinator/issues/391)) ([48af50e](https://github.com/JustinBeckwith/linkinator/commit/48af50e787731204aeb7eff41325c62291311e45)) ### [`v3.0.3`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.3) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.2...v3.0.3) ##### Bug Fixes - export getConfig from index ([#​371](https://github.com/JustinBeckwith/linkinator/issues/371)) ([0bc0355](https://github.com/JustinBeckwith/linkinator/commit/0bc0355c7e2ea457f247e6b52d1577b8c4ecb3a1)) ### [`v3.0.2`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.2) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.1...v3.0.2) ##### Bug Fixes - allow server root with trailing slash ([#​370](https://github.com/JustinBeckwith/linkinator/issues/370)) ([8adf6b0](https://github.com/JustinBeckwith/linkinator/commit/8adf6b025fda250e38461f1cdad40fe08c3b3b7c)) ### [`v3.0.1`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.1) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.0...v3.0.1) ##### Bug Fixes - decode path parts in local web server ([#​369](https://github.com/JustinBeckwith/linkinator/issues/369)) ([4696a0c](https://github.com/JustinBeckwith/linkinator/commit/4696a0c38c341b178ed815f47371fca955979feb)) ### [`v3.0.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.0) [Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v2.16.2...v3.0.0) ##### Bug Fixes - **deps:** update dependency chalk to v5 ([#​362](https://github.com/JustinBeckwith/linkinator/issues/362)) ([4b17a8d](https://github.com/JustinBeckwith/linkinator/commit/4b17a8d87b649eaf813428f8ee6955e1d21dae4f)) - feat!: convert to es modules, drop node 10 ([#​359](https://github.com/JustinBeckwith/linkinator/issues/359)) ([efee299](https://github.com/JustinBeckwith/linkinator/commit/efee299ab8a805accef751eecf8538915a4e7783)), closes [#​359](https://github.com/JustinBeckwith/linkinator/issues/359) ##### BREAKING CHANGES - this module now requires node.js 12 and above, and has moved to es modules by default. </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-containeranalysis).
I (think I) have a fix here for #422 but writing the test for it has been troublesome for me, most likely due to my lack of understanding with streams. Hopefully @stephenplusplus can help!
The test is passing (all asserts pass and done is called) and then immediately failing due to stream.end being called on a stream that (I guess) no longer exists?
I'm getting the following error when running the test included in this PR and don't know how to fix: