GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Storage streams use 'complete' event for end of stream but built-in streams use 'finish' · Issue #362 · googleapis/google-cloud-node

Storage streams use 'complete' event for end of stream but built-in streams use 'finish'  #362

New issue
Copy link
New issue
Copy link
Closed
Closed
Storage streams use 'complete' event for end of stream but built-in streams use 'finish' #362
Copy link
Assignees
ryanseys
Labels
api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.
Milestone
Storage Stable

Description

@ryanseys
ryanseys
opened on Jan 23, 2015
Issue body actions

As was raised in #340, I looked into why there was a discrepancy between what the developer thought and what was the real case. There was a suggestion made to update our docs, but our docs aren't the issue here. A snippet from the tests shows the issue:

Using 'finish' event:

file.createReadStream()
.pipe(fs.createWriteStream(tmpFilePath))
.on('error', done)
.on('finish', function() {
  file.delete(function(err) {
    assert.ifError(err);

    fs.readFile(tmpFilePath, function(err, data) {
      assert.equal(data, fileContent);
      done();
    });
  });
});

Using 'complete' event:

var file = bucket.file(filenames[0]);
fs.createReadStream(files.logo.path)
  .pipe(file.createWriteStream())
  .on('error', done)
  .on('complete', function() {
    file.copy(filenames[1], function(err, copiedFile) {
      assert.ifError(err);
      copiedFile.copy(filenames[2], done);
    });
  });

Seems the only difference is the type of file that is getting piped to. In the first case, it's a regular stream from fs and in the second it's our implementation of the storage file write stream.

So my question is, should we use a consistent finish event everywhere or is this by-design or otherwise okay?

Activity

Next
  1. ryanseys
    added
    type: questionRequest for information or clarification. Not an issue.
    opinions wanted
    api: storageIssues related to the Cloud Storage API.
    on Jan 23, 2015
  2. stephenplusplus commented on Jan 23, 2015

    @stephenplusplus
    stephenplusplus
    on Jan 23, 2015
    Contributor
    More actions

    Our complete event comes from request: https://github.com/request/request/blob/e33a883dd412dc7a1fdd1e1f282e840faa540609/request.js#L1224

    Being consistent with fs would be nice, but off hand, I'm not sure we can do that.

  3. ryanseys commented on Jan 30, 2015

    @ryanseys
    ryanseys
    on Jan 30, 2015
    ContributorAuthor
    More actions

    Are you sure? I thought we intercept pretty much every event and emit our own events.

    I'm looking at code here and here for example.

  4. stephenplusplus commented on Feb 2, 2015

    @stephenplusplus
    stephenplusplus
    on Feb 2, 2015
    Contributor
    More actions

    Ooh, I forgot about our new proxy stream. Yeah, we should be able to emit whatever we choose in these cases.

  5. jgeewax
    modified the milestone: Storage Stable on Feb 2, 2015
  6. stephenplusplus commented on Feb 5, 2015

    @stephenplusplus
    stephenplusplus
    on Feb 5, 2015
    Contributor
    More actions

    This is quite complex.

    A native readable stream is done when it emits 'end', which is the same time the stream is .end()-ed. The end listener doesn't receive arguments, and if you pass arguments to stream.end(), they get written to the stream immediately prior to being ended. I wonder if this is why request uses complete, so they can do some post-processing before emitting the response headers/body/status arguments.

    I'm okay with keeping complete as the consistent event for readable and writable end signals.

  7. ryanseys commented on Feb 5, 2015

    @ryanseys
    ryanseys
    on Feb 5, 2015
    ContributorAuthor
    More actions

    Oh yeah, good observation. That looks like exactly what they are doing. I'm happy with this too. It just makes it look weird when you have pipe with different streams, but in either case you have to make sure you're using the right event. complete as a consistent "yo, im done now" event is good for me.

  8. ryanseys
    closed this as completedon Feb 5, 2015
  9. JustinBeckwith
    assigned
    ryanseys
    on Feb 1, 2021
  10. sofisl
    added 2 commits that reference this issue on Sep 27, 2022

    feat: face and person detection samples (#362)

    84d636a

    chore: release 2.7.0

    5c98823
  11. sofisl
    added a commit that references this issue on Oct 13, 2022

    build: update copyright year to 2022 (#362)

    8fc44f3
  12. 15 remaining items

  13. miguelvelezsa
    added a commit that references this issue on Jul 23, 2025

    test: don't run Pub/Sub system tests (#362)

    53acdb8
  14. sofisl
    added 3 commits that reference this issue on Jan 27, 2026

    build: add lint script (#362)

    051833b

    build: add lint script (#362)

    57df004

    build: add lint script (#362)

    d8453f7
  15. GautamSharda
    added a commit that references this issue on Feb 25, 2026

    chore(deps): update dependency jsdoc-fresh to v3 (#362)

    97f29a9
  16. sofisl
    added 2 commits that reference this issue on Feb 26, 2026

    chore: update auto-generated config (#362)

    ee71c5e

    chore: migrate code from googleapis/gcp-metadata (#53)

    fa9a454
  17. codyoss
    added 2 commits that reference this issue on Mar 9, 2026

    build: pin compodoc (#362)

    ff3920f

    build: pin compodoc (#362)

    625df79
  18. GautamSharda
    added 2 commits that reference this issue on Mar 11, 2026

    refactor(ts): added ts style fix for src/util.ts (#362)

    2402b0e

    refactor: change error message format to multiline (#362)

    9622602
  19. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    refactor: use object.assign and drop lodash.flatten (#362)

    d8342ca

    refactor: use object.assign and drop lodash.flatten (#362)

    51c5174
  20. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    refactor: use object.assign and drop lodash.flatten (#362)

    e2eaa6a
  21. thiyaguk09
    added a commit that references this issue on May 5, 2026

    refactor: use object.assign and drop lodash.flatten (googleapis#362)

    67fa728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ryanseys
    ryanseys

Labels

api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    • Storage Stable

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.