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

build-assets fails with npm error: TypeError: Invalid non-string/buffer chunk #859

Closed
jangrewe opened this issue Mar 18, 2018 · 14 comments
Closed
Assignees
Labels
assets Related to the assets feature confirmed bug Something isn't working

Comments

@jangrewe
Copy link

Hi, i finally wanted to do my first live deployment, but unfortunately i'm not able to successfully compile the assets. My CI jobs always fail with either of these errors:

Building assets for production
------------------------------

> npm run uf-bundle-build

> @userfrosting/userfrosting@4.1.0 uf-bundle-build /srv/www/dev.betadiff.com/build
> gulp bundle-build

[00:51:16] Using gulpfile /srv/www/dev.betadiff.com/build/gulpfile.js
[00:51:16] Starting 'bundle-build'...
[00:51:19] Finished 'bundle-build' after 3.09 s
> npm run uf-bundle

> @userfrosting/userfrosting@4.1.0 uf-bundle /srv/www/dev.betadiff.com/build
> gulp bundle

[00:51:20] Using gulpfile /srv/www/dev.betadiff.com/build/gulpfile.js
[00:51:20] Starting 'bundle'...
[00:51:20] Bundle 'js/main.scripts' using vendor/bootstrap/dist/js/bootstrap.js
[00:51:20] ERROR in custom transforms for 'js/main.scripts':
[00:51:20] TypeError: Invalid non-string/buffer chunk
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @userfrosting/userfrosting@4.1.0 uf-bundle: `gulp bundle`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @userfrosting/userfrosting@4.1.0 uf-bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/www/.npm/_logs/2018-03-18T23_51_20_807Z-debug.log

or

Building assets for production
------------------------------

> npm run uf-bundle-build

> @userfrosting/userfrosting@4.1.0 uf-bundle-build /builds/dcd7ec86/0/jan/betadiff/build
> gulp bundle-build

[23:52:21] Using gulpfile /builds/dcd7ec86/0/jan/betadiff/build/gulpfile.js
[23:52:21] Starting 'bundle-build'...
[23:52:24] Finished 'bundle-build' after 3.58 s
> npm run uf-bundle

> @userfrosting/userfrosting@4.1.0 uf-bundle /builds/dcd7ec86/0/jan/betadiff/build
> gulp bundle

[23:52:26] Using gulpfile /builds/dcd7ec86/0/jan/betadiff/build/gulpfile.js
[23:52:26] Starting 'bundle'...
[23:52:27] Bundle 'js/form-widgets.scripts' using vendor/speakingurl/speakingurl.min.js
[23:52:27] ERROR in custom transforms for 'js/form-widgets.scripts':
[23:52:27] TypeError: Invalid non-string/buffer chunk

npm ERR! Linux 4.9.0-4-amd64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "uf-bundle" "--prefix" "/builds/dcd7ec86/0/jan/betadiff/build"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! @userfrosting/userfrosting@4.1.0 uf-bundle: `gulp bundle`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @userfrosting/userfrosting@4.1.0 uf-bundle script 'gulp bundle'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @userfrosting/userfrosting package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp bundle
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs @userfrosting/userfrosting
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls @userfrosting/userfrosting
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /builds/dcd7ec86/0/jan/betadiff/npm-debug.log

I'm tryin both manually and in a Docker image (see below), and it's always one of these two - no pattern to when which one happens.

The Dockerfile i'm using:

FROM php:7.1-alpine

RUN echo '{ "allow_root": true }' > /root/.bowerrc

RUN apk add --no-cache git nodejs libpng-dev \
 && docker-php-ext-install gd

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_NO_INTERACTION 1
ENV COMPOSER_HOME /cache/.composer
ENV bower_storage__packages /cache/.bower/packages
ENV bower_storage__registry /cache/.bower/registry
ENV bower_storage__links /cache/.bower/links
RUN npm config set cache /cache/.npm \
 && npm config set color false \
 && npm set progress false

WORKDIR /opt

The gulp debug log isn't that helpful either:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli   '/usr/bin/npm',
1 verbose cli   'run',
1 verbose cli   'uf-bundle',
1 verbose cli   '--prefix',
1 verbose cli   '/srv/www/dev.betadiff.com/build' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'preuf-bundle', 'uf-bundle', 'postuf-bundle' ]
5 info lifecycle @userfrosting/userfrosting@4.1.0~preuf-bundle: @userfrosting/userfrosting@4.1.0
6 info lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: @userfrosting/userfrosting@4.1.0
7 verbose lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: unsafe-perm in lifecycle true
8 verbose lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/srv/www/dev.betadiff.com/build/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
9 verbose lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: CWD: /srv/www/dev.betadiff.com/build
10 silly lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: Args: [ '-c', 'gulp bundle' ]
11 silly lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: Returned: code: 1  signal: null
12 info lifecycle @userfrosting/userfrosting@4.1.0~uf-bundle: Failed to exec uf-bundle script
13 verbose stack Error: @userfrosting/userfrosting@4.1.0 uf-bundle: `gulp bundle`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid @userfrosting/userfrosting@4.1.0
15 verbose cwd /srv/www/dev.betadiff.com
16 verbose Linux 4.9.0-4-amd64
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "uf-bundle" "--prefix" "/srv/www/dev.betadiff.com/build"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error @userfrosting/userfrosting@4.1.0 uf-bundle: `gulp bundle`
22 error Exit status 1
23 error Failed at the @userfrosting/userfrosting@4.1.0 uf-bundle script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
@lcharette
Copy link
Member

What's your asset-bundles.json ? You should come to the chat to debug this.

( Ping @Silic0nS0ldier )

@Silic0nS0ldier
Copy link
Member

TypeError: Invalid non-string/buffer chunk usually means that an incompatible Vinyl object made it into the stream. And because of the stupid way the bundler works, I've got no idea where its all gone wrong.

Its possible that this is caused by permission issues, so that's something worth exploring. Good luck with it. Problems like this are exactly what I'm been trying to address in milestone 4.2, so fingers crossed I'll these will at the very least be a little less obscure in the future.

@alexweissman
Copy link
Member

If this is a support question, it should be brought up on the forums or chat instead.

@jangrewe
Copy link
Author

It's not the permissions, on the host the files are all owned by www-data, and in the Docker container it's root, so unfortunately that's not the easy fix. ;-)
I'll drop by in the chat later tonight, thanks for the pointer!

@lcharette
Copy link
Member

I successfully replicated last night on a fresh install of the master branch and Homestead.

It only happen when building the assets for production. All goes down to that ERROR in custom transforms for 'js/main.scripts': error. This is not present in 4.2 develop branch since that process has been refactored.

@lcharette lcharette reopened this Mar 23, 2018
@lcharette lcharette added the confirmed bug Something isn't working label Mar 23, 2018
@lcharette lcharette added this to the 4.1.17 milestone Mar 23, 2018
@Silic0nS0ldier
Copy link
Member

Oh joy. This is going to be hell to figure out. This is something unrelated to gulp-uf-bundle-assets though. If it were, 4.2 would have still been affected since the bundling refactor is incomplete.

@jangrewe
Copy link
Author

Thanks for looking into this! <3

@alexweissman alexweissman changed the title build-assets always fails build-assets fails with npm error: TypeError: Invalid non-string/buffer chunk Mar 23, 2018
@lcharette
Copy link
Member

So far I found out it appeared after something changed in one of the node_module dependencies. An older install with different dependencies version doesn't have this problem. And it's probably one of these :

duplexify
flagged-respawn
gulp-clean-css
gulp-uf-bundle-assets
liftoff
process-nextick-args
ternary-stream
through2

I also can confirm it all goes down to this line (and the same line in the css bundle): https://github.com/Silic0nS0ldier/gulp-uf-bundle-assets/blob/master/lib/stream-files.js#L62

@Silic0nS0ldier
Copy link
Member

Had a crack at getting Vagrant running, it scream the whole time.
Got homestead running, I was assaulted with unrelated errors (can't even get npm install to finish).

In short, I won't be able to debug this myself, not with how busy I am atm.

@Silic0nS0ldier Silic0nS0ldier removed their assignment Mar 24, 2018
@Silic0nS0ldier
Copy link
Member

Worth nothing that this appears to impact Vagrant (according to @lcharette) and Docker. If this is caused by a gulp-uf-bundle-assets update, testing is as simple as dropping the version down and locking the range.

@jangrewe
Copy link
Author

jangrewe commented Mar 24, 2018

Thanks for checking!
I downgraded gulp-uf-bundle-assets to 2.28.1 and it still failed, but went down another step to 2.28.0 and now the assets compile!

For those also affected: edit build/package.json from ^2.27.2 to 2.28.0 (no caret)

@Silic0nS0ldier
Copy link
Member

Hmm. Wonder what specifically caused it. In any case, I'll see to getting the affected versions tagged, and a warning attached. Should stop npm from pulling impacted versions, and inform people of the potential issue when it does get pulled.

Moving issue userfrosting/gulp-uf-bundle-assets#5

@lcharette
Copy link
Member

I'll leave it open here until it's fixed. People getting this error in UF will end up here.

@lcharette lcharette reopened this Mar 24, 2018
@alexweissman alexweissman added the assets Related to the assets feature label May 11, 2018
@alexweissman alexweissman removed this from the 4.1.18 milestone May 13, 2018
@Silic0nS0ldier Silic0nS0ldier self-assigned this Nov 14, 2018
@Silic0nS0ldier
Copy link
Member

A patch for the problem has been made for 4.1 and for 4.2 gulp-uf-bundle-assets (now @userfrosting/gulp-bundle-assets) has been completely rewritten to the point where this problem cannot trigger such a failure (since it doesn't mess with files itself, and just directs them where they need to go).

There hasn't been any activity here for over 6 months, and fixes are deployed (and in use) so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assets Related to the assets feature confirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants