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

Emit errors from upstream on file upload #426

Merged
merged 1 commit into from
Mar 5, 2015
Merged

Emit errors from upstream on file upload #426

merged 1 commit into from
Mar 5, 2015

Conversation

ryanseys
Copy link
Contributor

@ryanseys ryanseys commented Mar 4, 2015

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:

> mocha test/*

  File
    createWriteStream
      ✓ should re-emit errors
      1) should re-emit errors

  1 passing (23ms)
  1 failing

  1) File createWriteStream should re-emit errors:
     Uncaught TypeError: Cannot read property 'ending' of undefined
      at Duplexify.end (/Users/ryanseys/gcloud-node/node_modules/duplexify/index.js:218:27)
      at handleError (/Users/ryanseys/gcloud-node/lib/storage/file.js:1064:12)
      at DestroyableTransform.<anonymous> (/Users/ryanseys/gcloud-node/lib/storage/file.js:992:7)
      at DestroyableTransform.emit (events.js:129:20)
      at Immediate._onImmediate (/Users/ryanseys/gcloud-node/test/storage/file.js:553:18)
      at processImmediate [as _immediateCallback] (timers.js:358:17)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 4, 2015
@@ -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.

@stephenplusplus
Copy link
Contributor

I believe handleError doesn't need to end the stream. Errors are emitted back to the stream that was passed into startResumableUpload_, which ends the stream there.

... 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.

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 5, 2015

PTAL 😄

stephenplusplus added a commit that referenced this pull request Mar 5, 2015
Emit errors from upstream on file upload
@stephenplusplus stephenplusplus merged commit 751d97f into googleapis:master Mar 5, 2015
@stephenplusplus
Copy link
Contributor

👍

@teddybearz
Copy link

Is it possible that handleError() being called twice? i.e. one error event and one complete event with error come back to back?

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 5, 2015

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!

@teddybearz
Copy link

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.

@stephenplusplus
Copy link
Contributor

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.

@stephenplusplus
Copy link
Contributor

@teddybearz I can't help but feel I'm missing your point. If I am, thanks for your patience.

@teddybearz
Copy link

The write stream will either emit an error or complete, it can't do both.
In theory yes, but for event driven code, it takes some efforts to enforce and maintain that. Maybe better not assume too much and prepare for the worst.

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 😄

@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 7, 2015

@teddybearz You might have some luck trying out https://github.com/tylertreat/Comcast 😄

chingor13 pushed a commit that referenced this pull request Aug 22, 2022
sofisl pushed a commit that referenced this pull request Sep 15, 2022
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
sofisl pushed a commit that referenced this pull request Sep 27, 2022
sofisl pushed a commit that referenced this pull request Oct 12, 2022
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
sofisl pushed a commit that referenced this pull request Oct 13, 2022
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
sofisl pushed a commit that referenced this pull request Nov 9, 2022
sofisl pushed a commit that referenced this pull request Nov 10, 2022
…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
sofisl pushed a commit that referenced this pull request Nov 11, 2022
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
sofisl pushed a commit that referenced this pull request Nov 11, 2022
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.
sofisl pushed a commit that referenced this pull request Nov 11, 2022
sofisl pushed a commit that referenced this pull request Nov 11, 2022
Update npm scripts: add clean, prelint, prefix; make sure that lint and fix are set properly. Use post-process feature of synthtool.
sofisl pushed a commit that referenced this pull request Nov 11, 2022
[![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 ([#&#8203;508](https://github.com/JustinBeckwith/linkinator/issues/508)) ([2cab633](https://github.com/JustinBeckwith/linkinator/commit/2cab633c9659eb10794a4bac06f8b0acdc3e2c0c))

##### BREAKING CHANGES

-   The commits in [#&#8203;507](https://github.com/JustinBeckwith/linkinator/issues/507) and [#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;362](https://github.com/JustinBeckwith/linkinator/issues/362)) ([4b17a8d](https://github.com/JustinBeckwith/linkinator/commit/4b17a8d87b649eaf813428f8ee6955e1d21dae4f))

-   feat!: convert to es modules, drop node 10 ([#&#8203;359](https://github.com/JustinBeckwith/linkinator/issues/359)) ([efee299](https://github.com/JustinBeckwith/linkinator/commit/efee299ab8a805accef751eecf8538915a4e7783)), closes [#&#8203;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).
sofisl pushed a commit that referenced this pull request Nov 11, 2022
sofisl pushed a commit that referenced this pull request Nov 17, 2022
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.

4 participants