chrisdwheatley / netlify-plugin-image-optim

Optimize images as part of your Netlify build process. Optimizes PNG, JPEG, GIF and SVG file formats.
MIT License
63 stars 11 forks source link

`Cannot create property 'message' on string 'Error in parsing SVG: Unbound namespace prefix: "xlink"` #11

Open ehmicky opened 4 years ago

ehmicky commented 4 years ago

The following error is happening in some builds:

Cannot create property 'message' on string 'Error in parsing SVG: Unbound namespace prefix: "xlink"
Line: 0
Column: 456
Char: >' 
    /opt/buildhome/.netlify-build-plugins/node_modules/imagemin-keep-folder/index.js:48:16 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:29:30 async onPostBuild
    src/plugins/child/run.js:18:3 async Object.run
    src/plugins/child/main.js:38:38 async handleEvent
    src/plugins/ipc.js:97:9 async process.<anonymous>

The build's repository is here. Unfortunately, the build logs do not show any additional information. Do you know what the problem might be?

chrisdwheatley commented 4 years ago

It looks like the issue may have been fixed by this commit https://github.com/morgantaylor/legos/commit/7496af02c72f633cb155125926624100121036da.

I forked the repo and built it on Netlify with this plugin and could no longer reproduce the issue.

ehmicky commented 4 years ago

Thanks for your answer!

The similar error message happened yesterday:

Cannot create property 'message' on string 'Error in parsing SVG: Invalid attribute name
Line: 1
Column: 57
Char: "' 
    /opt/buildhome/.netlify-build-plugins/node_modules/imagemin-keep-folder/index.js:48:16 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:29:30 async onPostBuild
    src/plugins/child/run.js:18:3 async Object.run
    src/plugins/child/main.js:38:38 async handleEvent
    src/plugins/ipc.js:97:9 async process.<anonymous>

Is this the same error?

chrisdwheatley commented 4 years ago

It's not quite the same error but looks like another one propagating from svgo. Are you receiving these errors from your internal logs? What happens to the build when the error happens?

ehmicky commented 4 years ago

This seemed to have happened again:

2:17:41 AM: Build ready to start
2:18:00 AM: build-image version: 30f629161c0736b1a3ecd8b418e5eeffab5c0faf
2:18:00 AM: build-image tag: v3.3.14
2:18:00 AM: buildbot version: a383ed3390159974f55f285b04457b44cb49efb0
2:18:00 AM: Fetching cached dependencies
2:18:00 AM: Starting to download cache of 258.3MB
2:18:05 AM: Finished downloading cache in 5.490912195s
2:18:05 AM: Starting to extract cache
2:18:16 AM: Finished extracting cache in 10.160428238s
2:18:16 AM: Finished fetching cache in 15.730678933s
2:18:16 AM: Starting to prepare the repo for build
2:18:16 AM: Preparing Git Reference refs/heads/master
2:18:19 AM: Starting build script
2:18:19 AM: Installing dependencies
2:18:20 AM: Started restoring cached node version
2:18:23 AM: Finished restoring cached node version
2:18:23 AM: Attempting node version '12' from .nvmrc
2:18:24 AM: v12.18.0 is already installed.
2:18:25 AM: Now using node v12.18.0 (npm v6.14.4)
2:18:25 AM: Started restoring cached build plugins
2:18:25 AM: Finished restoring cached build plugins
2:18:25 AM: Attempting ruby version 2.6.2, read from environment
2:18:27 AM: Using ruby version 2.6.2
2:18:27 AM: Using PHP version 5.6
2:18:27 AM: 5.2 is already installed.
2:18:27 AM: Using Swift version 5.2
2:18:27 AM: Started restoring cached node modules
2:18:27 AM: Finished restoring cached node modules
2:18:27 AM: Started restoring cached yarn cache
2:18:27 AM: Finished restoring cached yarn cache
2:18:28 AM: Installing NPM modules using Yarn version 1.12.1
2:18:28 AM: yarn install v1.12.1
2:18:28 AM: [1/4] Resolving packages...
2:18:29 AM: success Already up-to-date.
2:18:29 AM: Done in 1.02s.
2:18:29 AM: NPM modules installed using Yarn
2:18:30 AM: Started restoring cached go cache
2:18:30 AM: Finished restoring cached go cache
2:18:30 AM: go version go1.12 linux/amd64
2:18:30 AM: go version go1.12 linux/amd64
2:18:30 AM: Installing missing commands
2:18:30 AM: Verify run directory
2:18:31 AM: ​
2:18:31 AM: ┌─────────────────────────────┐
2:18:31 AM: │        Netlify Build        │
2:18:31 AM: └─────────────────────────────┘
2:18:31 AM: ​
2:18:31 AM: ❯ Version
2:18:31 AM:   @netlify/build 1.0.16
2:18:31 AM: ​
2:18:31 AM: ❯ Flags
2:18:31 AM:   mode: buildbot
2:18:31 AM: ​
2:18:31 AM: ❯ Current directory
2:18:31 AM:   /opt/build/repo
2:18:31 AM: ​
2:18:31 AM: ❯ Config file
2:18:31 AM:   /opt/build/repo/netlify.toml
2:18:31 AM: ​
2:18:31 AM: ❯ Context
2:18:31 AM:   production
2:18:31 AM: ​
2:18:31 AM: ❯ Installing plugins
2:18:31 AM:    - netlify-plugin-hugo-cache-resources
2:18:32 AM: ​
2:18:32 AM: ❯ Missing plugins
2:18:32 AM:   The following plugins should be installed either via the Netlify app or as a "dependency" inside your project's "package.json"
2:18:32 AM:    - netlify-plugin-hugo-cache-resources
2:18:33 AM: ​
2:18:33 AM: ❯ Loading plugins
2:18:33 AM:    - netlify-plugin-hugo-cache-resources@0.1.4 from Netlify app
2:18:33 AM:    - netlify-plugin-image-optim@0.3.0 from Netlify app
2:18:36 AM: ​
2:18:36 AM: ┌────────────────────────────────────────────────────────────────┐
2:18:36 AM: │ 1. onPreBuild command from netlify-plugin-hugo-cache-resources │
2:18:36 AM: └────────────────────────────────────────────────────────────────┘
2:18:36 AM: ​
2:18:36 AM: No cache found for resources folder
2:18:36 AM: ​
2:18:36 AM: (netlify-plugin-hugo-cache-resources onPreBuild completed in 15ms)
2:18:36 AM: ​
2:18:36 AM: ┌────────────────────────────────────┐
2:18:36 AM: │ 2. build.command from netlify.toml │
2:18:36 AM: └────────────────────────────────────┘
2:18:36 AM: ​
2:18:36 AM: $ yarn build
2:18:36 AM: 
2:18:36 AM: yarn run v1.12.1
2:18:36 AM: 
2:18:36 AM: 
2:18:36 AM: $ rimraf dist
2:18:36 AM: 
2:18:36 AM: $ npm run build:webpack && npm run build:hugo
2:18:37 AM: npm
2:18:37 AM:  WARN
2:18:37 AM: lifecycle The node binary used for scripts is /tmp/yarn--1592007516670-0.6773059318896344/node but npm is using /opt/buildhome/.nvm/versions/node/v12.18.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
2:18:37 AM: > victor-hugo@1.0.0 build:webpack /opt/build/repo
2:18:37 AM: > cross-env NODE_ENV=production webpack --config webpack.prod.js
2:18:51 AM: Hash: d52ac2430e7e31469c89
2:18:51 AM: Version: webpack 4.43.0
2:18:51 AM: Time: 12431ms
2:18:51 AM: Built at: 06/13/2020 12:18:51 AM
2:18:51 AM:                    Asset       Size  Chunks                                Chunk Names
2:18:51 AM:         admin/index.html  328 bytes          [emitted]
2:18:51 AM:             cms.d52ac.js   4.16 MiB       0  [emitted] [immutable]  [big]  cms
2:18:51 AM: cms.d52ac.js.LICENSE.txt   4.47 KiB          [emitted]
2:18:51 AM:              fonts/.keep    0 bytes          [emitted]
2:18:51 AM:           main.d52ac.css     84 KiB       1  [emitted] [immutable]         main
2:18:51 AM:            main.d52ac.js   3.72 KiB       1  [emitted] [immutable]         main
2:18:51 AM: Entrypoint main = main.d52ac.css main.d52ac.js
2:18:51 AM: Entrypoint cms [big] = cms.d52ac.js
2:18:51 AM:  [8] ./node_modules/to-string-loader/src/to-string.js!./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/src!./node_modules/sass-loader/dist/cjs.js!./src/css/main.css 338 bytes {0} [built]
2:18:51 AM:  [9] ./src/index.js 122 bytes {1} [built]
2:18:51 AM: [10] ./src/css/main.css 672 bytes {1} [built]
2:18:51 AM: [12] ./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/src!./node_modules/sass-loader/dist/cjs.js!./src/css/main.css 39 bytes {1} [built]
2:18:51 AM: [18] ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/src!./node_modules/sass-loader/dist/cjs.js!./src/css/main.css 85.9 KiB {0} [built]
2:18:51 AM: [34] ./src/js/cms.js + 6 modules 35 KiB {0} [built]
2:18:51 AM:      | ./src/js/cms.js 860 bytes [built]
2:18:51 AM:      | ./src/js/cms-preview-templates/home.js 6.62 KiB [built]
2:18:51 AM:      | ./src/js/cms-preview-templates/post.js 4.36 KiB [built]
2:18:51 AM:      | ./src/js/cms-preview-templates/products.js 8.63 KiB [built]
2:18:51 AM:      | ./src/js/cms-preview-templates/values.js 5.37 KiB [built]
2:18:51 AM:      | ./src/js/cms-preview-templates/contact.js 4.8 KiB [built]
2:18:51 AM:      |     + 1 hidden module
2:18:51 AM:     + 30 hidden modules
2:18:51 AM: WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
2:18:51 AM: This can impact web performance.
2:18:51 AM: Assets:
2:18:51 AM:   cms.d52ac.js (4.16 MiB)
2:18:51 AM: WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
2:18:51 AM: Entrypoints:
2:18:51 AM:   cms (4.16 MiB)
2:18:51 AM:       cms.d52ac.js
2:18:51 AM: 
2:18:51 AM: WARNING in webpack performance recommendations:
2:18:51 AM: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
2:18:51 AM: For more info visit https://webpack.js.org/guides/code-splitting/
2:18:51 AM: Child html-webpack-plugin for "admin/index.html":
2:18:51 AM:      1 asset
2:18:51 AM:     Entrypoint undefined = admin/index.html
2:18:51 AM:     [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/cms.html 602 bytes {0} [built]
2:18:51 AM:     [2] (webpack)/buildin/global.js 472 bytes {0} [built]
2:18:51 AM:     [3] (webpack)/buildin/module.js 497 bytes {0} [built]
2:18:51 AM:         + 1 hidden module
2:18:51 AM: Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/postcss-loader/src/index.js!node_modules/sass-loader/dist/cjs.js!src/css/main.css:
2:18:51 AM:     Entrypoint mini-css-extract-plugin = *
2:18:51 AM:     [0] ./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/src!./node_modules/sass-loader/dist/cjs.js!./src/css/main.css 85.9 KiB {0} [built]
2:18:51 AM:         + 1 hidden module
2:18:52 AM: npm
2:18:52 AM:  WARN lifecycle The node binary used for scripts is /tmp/yarn--1592007516670-0.6773059318896344/node but npm is using /opt/buildhome/.nvm/versions/node/v12.18.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
2:18:52 AM: > victor-hugo@1.0.0 build:hugo /opt/build/repo
2:18:52 AM: > hugo -d ../dist -s site -v
2:18:52 AM: INFO 2020/06/13 00:18:52 No translation bundle found for default language "en"
2:18:52 AM: INFO 2020/06/13 00:18:52 Translation func for language en not found, use default.
2:18:52 AM: INFO 2020/06/13 00:18:52 i18n not initialized; if you need string translations, check that you have a bundle in /i18n that matches the site language or the default language.
2:18:52 AM: INFO 2020/06/13 00:18:52 Using config file:
2:18:52 AM: Building sites … INFO 2020/06/13 00:18:52 syncing static files to /opt/build/repo/dist/
2:18:52 AM:                   |
2:18:52 AM:  EN
2:18:52 AM: -------------------+-----
2:18:52 AM:   Pages            |  9
2:18:52 AM:   Paginator pages  |  0
2:18:52 AM:   Non-page files   |  0
2:18:52 AM:   Static files     | 47
2:18:52 AM:   Processed images |  0
2:18:52 AM:   Aliases          |  1
2:18:52 AM:   Sitemaps         |  1
2:18:52 AM:   Cleaned          |  0
2:18:52 AM: Total in 58 ms
2:18:52 AM: Done in 15.95s.
2:18:52 AM: ​
2:18:52 AM: (build.command completed in 16.2s)
2:18:52 AM: ​
2:18:52 AM: ┌─────────────────────────────────────────────────────────────────┐
2:18:52 AM: │ 3. onPostBuild command from netlify-plugin-hugo-cache-resources │
2:18:52 AM: └─────────────────────────────────────────────────────────────────┘
2:18:52 AM: ​
2:18:52 AM: No resources folder cached
2:18:52 AM: ​
2:18:52 AM: (netlify-plugin-hugo-cache-resources onPostBuild completed in 14ms)
2:18:52 AM: ​
2:18:52 AM: ┌────────────────────────────────────────────────────────┐
2:18:52 AM: │ 4. onPostBuild command from netlify-plugin-image-optim │
2:18:52 AM: └────────────────────────────────────────────────────────┘
2:18:52 AM: ​
2:18:53 AM: ​
2:18:53 AM: ┌────────────────────────────────────────────────────┐
2:18:53 AM: │ Plugin "netlify-plugin-image-optim" internal error │
2:18:53 AM: └────────────────────────────────────────────────────┘
2:18:53 AM: ​
2:18:53 AM:   Error message
2:18:53 AM:   TypeError: Cannot create property 'message' on string 'Error in parsing SVG: Invalid attribute name
2:18:53 AM:   Line: 4
2:18:53 AM:   Column: 1
2:18:53 AM:   Char: <'
2:18:53 AM: ​
2:18:53 AM:   Plugin details
2:18:53 AM:   Package:        netlify-plugin-image-optim
2:18:53 AM:   Version:        0.3.0
2:18:53 AM:   Repository:     git+https://github.com/chrisdwheatley/netlify-plugin-image-optim.git
2:18:53 AM:   npm link:       https://www.npmjs.com/package/netlify-plugin-image-optim
2:18:53 AM:   Report issues:  https://github.com/chrisdwheatley/netlify-plugin-image-optim/issues
2:18:53 AM: ​
2:18:53 AM:   Error location
2:18:53 AM:   In "onPostBuild" event in "netlify-plugin-image-optim" from Netlify app
2:18:53 AM:       at /opt/buildhome/.netlify-build-plugins/node_modules/imagemin-keep-folder/index.js:48:16
2:18:53 AM:       at async Promise.all (index 21)
2:18:53 AM:       at async onPostBuild (/opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:29:30)
2:18:53 AM:       at async Object.run (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/run.js:18:3)
2:18:53 AM:       at async handleEvent (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/main.js:38:38)
2:18:53 AM:       at async process.<anonymous> (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/ipc.js:97:9)
2:18:53 AM: ​
2:18:53 AM:   Resolved config
2:18:53 AM:   build:
2:18:53 AM:     command: yarn build
2:18:53 AM:     publish: /opt/build/repo/dist
2:18:53 AM:   plugins:
2:18:53 AM:     - inputs: {}
2:18:53 AM:       origin: ui
2:18:53 AM:       package: netlify-plugin-hugo-cache-resources
2:18:53 AM:     - inputs: {}
2:18:53 AM:       origin: ui
2:18:53 AM:       package: netlify-plugin-image-optim
2:18:53 AM: Caching artifacts
2:18:53 AM: Started saving node modules
2:18:53 AM: Finished saving node modules
2:18:53 AM: Started saving build plugins
2:18:53 AM: Finished saving build plugins
2:18:53 AM: Started saving yarn cache
2:18:53 AM: Finished saving yarn cache
2:18:53 AM: Started saving pip cache
2:18:53 AM: Finished saving pip cache
2:18:53 AM: Started saving emacs cask dependencies
2:18:54 AM: Finished saving emacs cask dependencies
2:18:54 AM: Started saving maven dependencies
2:18:54 AM: Finished saving maven dependencies
2:18:54 AM: Started saving boot dependencies
2:18:54 AM: Finished saving boot dependencies
2:18:54 AM: Started saving go dependencies
2:18:54 AM: Finished saving go dependencies
2:18:54 AM: Error running command: Build script returned non-zero exit code: 1
2:18:54 AM: Failing build: Failed to build site
2:18:54 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
2:18:54 AM: Finished processing build request in 53.788355622s

The repository and commit was this one.

ehmicky commented 4 years ago

Not sure if this one is the same, but this error just happened:

Cannot create property 'message' on string 'Error in parsing SVG: Unexpected close tag
Line: 4
Column: 6
Char: >' 
    /opt/buildhome/.netlify-build-plugins/node_modules/imagemin-keep-folder/index.js:48:16 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:29:30 async onPostBuild
    src/plugins/child/run.js:13:3 async Object.run
    src/plugins/child/main.js:34:38 async handleEvent
    src/plugins/ipc.js:102:9 async process.<anonymous>

It seems like there is also an issue with error handling in imagemin-keep-folder, where they assume that thrown errors are Error instances while, in this case, a string was thrown.

ehmicky commented 4 years ago

This appears to the problem: https://github.com/Nakachuuuu/imagemin-keep-folder/issues/1