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

SVGO not working on Azure PaaS #46

Closed
markgibbons25 opened this issue Jan 14, 2019 · 3 comments
Closed

SVGO not working on Azure PaaS #46

markgibbons25 opened this issue Jan 14, 2019 · 3 comments

Comments

@markgibbons25
Copy link
Collaborator

I have Sitecore 9.0.1 on Azure PaaS with Dianoga 4.0.0, PNG and JPG optimisation works, but getting this exception on all SVG's.

40632 00:26:40 ERROR Dianoga: Unable to optimize /Project/xxx/Public/xxx/Icons/ico-twitter due to a processing error! It will be unchanged.
Exception: System.InvalidOperationException
Message: D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node.exe exited with unexpected exit code 1. Output:
at Module.require (module.js:353:17)
at Function.Module._load (module.js:300:12)
at Module.load (module.js:343:32)
at Object.Module._extensions..js (module.js:416:10)
at Module._compile (module.js:409:26)
at Object. (D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\colors\lib\colors.js:176:23)
at require (internal/module.js:12:17)
at Module.require (module.js:353:17)
at Function.Module._load (module.js:276:25)
at Function.Module._resolveFilename (module.js:325:15)
Error: Cannot find module './maps/rainbow'

^
throw err;

module.js:327

Source: Dianoga
at Dianoga.Optimizers.CommandLineToolOptimizer.ExecuteProcess(String arguments)
at Dianoga.Optimizers.CommandLineToolOptimizer.ProcessOptimizer(OptimizerArgs args)
at Dianoga.Optimizers.OptimizerProcessor.Process(OptimizerArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Dianoga.Processors.Pipelines.DianogaOptimize.ExtensionBasedOptimizer.ProcessOptimize(ProcessorArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Dianoga.MediaOptimizer.Process(MediaStream stream, MediaOptions options)

I have confirmed that the maps/rainbow.js file is being deployed.
I have confirmed that it is using the nodejs.exe in the App_Data\Dianoga Tools\SVGO\node.exe by checking the kudu console.

Thanks in advance!

@kamsar
Copy link
Owner

kamsar commented Feb 1, 2019

It sounds like the working directory may be incorrect or otherwise messing up node module resolution. I don't have a particular fix in mind, but you could try using https://www.npmjs.com/package/pkg (or this pre-packed but older release of svgop) as a command line invocation: https://github.com/twardoch/svgop

In the specific case of Azure, you might also be running into some sort of limitation on running executables. App Service has Node installed (you may need to upgrade the version), and you could consider invoking that system level Node on svgo instead.

If you figure out a workaround, I'd merge a PR to fix it.

@markgibbons25
Copy link
Collaborator Author

markgibbons25 commented Mar 11, 2020

Retested with 5.0 RC 4. Interestingly, it worked for about half the svg's on the page, other half various issues with timeouts and this error:

7244 22:37:53 ERROR Dianoga: Unable to optimize /Themes//images/icons/ico-search-white due to a processing error! It will be unchanged.
Exception: System.InvalidOperationException
Message: "D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node.exe "D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\bin\svgo" --input="D:\local\Temp\tmp7FC.tmp" --output="D:\local\Temp\tmp7FD.tmp" --disable=removeUselessDefs --disable=cleanupIDs" exited with unexpected exit code 1. Output: 
}
  ]
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\bin\\svgo'
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\lib\\svgo\\coa.js',
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\node_modules\\util.promisify\\index.js',
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\node_modules\\util.promisify\\implementation.js',
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\node_modules\\object.getownpropertydescriptors\\index.js',
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\node_modules\\object.getownpropertydescriptors\\implementation.js',
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\node_modules\\es-abstract\\2019\\CreateDataProperty.js',
	'D:\\home\\site\\wwwroot\\App_Data\\Dianoga Tools\\SVGO\\node_modules\\svgo\\node_modules\\es-abstract\\GetIntrinsic.js',
  requireStack: [
  code: 'MODULE_NOT_FOUND',
	at Module.require (internal/modules/cjs/loader.js:848:19) {
	at Function.Module._load (internal/modules/cjs/loader.js:723:14)
	at Module.load (internal/modules/cjs/loader.js:811:32)
	at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
	at Module._compile (internal/modules/cjs/loader.js:955:30)
	at Object.<anonymous> (D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\es-abstract\GetIntrinsic.js:165:12)
	at require (internal/modules/cjs/helpers.js:74:18)
	at Module.require (internal/modules/cjs/loader.js:848:19)
	at Function.Module._load (internal/modules/cjs/loader.js:686:27)
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\bin\svgo
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\lib\svgo\coa.js
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\util.promisify\index.js
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\util.promisify\implementation.js
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\object.getownpropertydescriptors\index.js
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\object.getownpropertydescriptors\implementation.js
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\es-abstract\2019\CreateDataProperty.js
- D:\home\site\wwwroot\App_Data\Dianoga Tools\SVGO\node_modules\svgo\node_modules\es-abstract\GetIntrinsic.js
Require stack:
Error: Cannot find module 'function-bind'

	^
	throw err;
internal/modules/cjs/loader.js:796

Source: Dianoga
   at Dianoga.Optimizers.CommandLineToolOptimizer.ExecuteProcess(String arguments)
   at Dianoga.Optimizers.CommandLineToolOptimizer.ProcessOptimizer(OptimizerArgs args)
   at Dianoga.Optimizers.OptimizerProcessor.Process(OptimizerArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Dianoga.Processors.Pipelines.DianogaOptimize.ExtensionBasedOptimizer.ProcessOptimize(ProcessorArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Dianoga.MediaOptimizer.Process(MediaStream stream, MediaOptions options)

@markgibbons25
Copy link
Collaborator Author

Changed to use https://github.com/twardoch/svgop which has resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants