workbox icon indicating copy to clipboard operation
workbox copied to clipboard

CDN publishing fails when part of the larger gulp publish chain

Open gauntface opened this issue 7 years ago • 7 comments

This is the error thrown by gulp publish-github when we do a release via gulp publish and all steps are chained.

[10:27:06] 'publish-github:generate-from-tags' errored after 1.05 min
[10:27:06] TypeError: Cannot read property 'objectMode' of undefined
    at Readable.Writable.write (/usr/local/google/home/mattgaunt/Projects/Code/workbox/node_modules/readable-stream/lib/_stream_writable.js:305:45)
    at ReadStream.ondata (_stream_readable.js:628:20)
    at emitOne (events.js:115:13)
    at ReadStream.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at ReadStream.Readable.push (_stream_readable.js:197:10)
    at onread (fs.js:2003:12)
    at FSReqWrap.wrapper [as oncomplete] (fs.js:664:17)

gauntface avatar Jan 09 '18 18:01 gauntface

I was digging into this a bit and it sounds like it could be the same thing as https://github.com/archiverjs/node-archiver/issues/288

It's unfortunate that the rejected promise within the gulp task leads to a real loss of stack context when the error is logged, but the 'publish-github:generate-from-tags task does call archiver, so that's one similarity. And that other bug report also involves a failure when the archive is created inside of a promise chain (in that case, Bluebird's promises).

I'm still working out how to reproduce this without running through the actual publishing workflow, ensuring that we don't end up accidentally publishing things on npm and GitHub, in order to test possible solutions.

jeffposnick avatar Jan 16 '18 21:01 jeffposnick

It turns out that the archiver module already returns a promise from its finalize() method:

https://github.com/archiverjs/node-archiver/blob/d43f922abcf2e9b407fa45591e0e8665fc0f8786/lib/core.js#L762-L795

(This isn't mentioned in the docs, but I filed a PR to fix that: https://github.com/archiverjs/node-archiver/pull/306.)

I'm going to put together a PR that refactors how we use archiver to take advantage of that Promise. I'm not sure whether it will fix the issue we're seeing, but it sounds like a good approach anyway.

jeffposnick avatar Jan 16 '18 21:01 jeffposnick

Boo. Just tried another gulp publish with #1179 merged, and I'm getting the exact same error.

jeffposnick avatar Jan 24 '18 16:01 jeffposnick

For future reference, while this bug is still open, you can resume the publishing process after this failure by running the following two commands:

$ gulp publish:cdn+git
$ gulp publish-demos

jeffposnick avatar Jan 24 '18 16:01 jeffposnick

This changed (sorry - but for the better).

Now run gulp publish this will do lerna process, and then run gulp publish-assets, which will do the github release package, publish to CDN and publish the demos.

Note: The gulp publish command will also log a message to run the second command - in case you forget.

gauntface avatar Feb 13 '18 01:02 gauntface

Breaking things up into two steps seems to be something that we're fine with, so I'm closing this out.

jeffposnick avatar May 22 '18 18:05 jeffposnick

FWIW, if you skip the test suite (gulp publish --distTag=latest --skipTests) then CDN publishing succeeds. So the current issue seems to be due to an interplay between our test runner and the CDN upload script.

jeffposnick avatar Aug 11 '21 18:08 jeffposnick