lasso-js / lasso

Advanced JavaScript module bundler, asset pipeline and optimizer
582 stars 75 forks source link

Processing CSS files with font declaration can cause EPERM 'operation not permitted' on rename #147

Closed alexheb closed 8 years ago

alexheb commented 8 years ago

The error occurs on Lasso 2.5.3., run on Windows. While I embed via require (synchronously or asynchronously) any CSS file which contains font links, i.e. awesome font, following CSS section causes the error:

@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?v=4.6.3');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.3') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.6.3') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.6.3') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.6.3') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.6.3#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

The reason - there is 'fontawesome-webfont.eot' referenced twice and lasso tries to copy the resource twice as well; two async rename operations are in place

/lasso/lib/writers/file-writer.js line 216

Full stack:

Error: Error while writing bundle "root-async (head, css)" Error: Error: Error while resolving resource URL for path "C:\LWO\lwo.web\x\fonts\fontawesome-webfont.eot". Error: Error: Error while writing reso
urce "C:\LWO\lwo.web\x\fonts\fontawesome-webfont.eot": Error: EPERM: operation not permitted, rename 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.eot.10172.7982' -> 'C:\LWO\lwo.web\y\root\l
wo$1.0.0\x\fonts\fontawesome-webfont.eot'
    at Error (native)
    at module.exports (C:\LWO\lwo.web\node_modules\raptor-util\createError.js:7:50)
    at done (C:\LWO\lwo.web\node_modules\lasso\lib\writers\Writer.js:82:23)
    at C:\LWO\lwo.web\node_modules\raptor-async\series.js:23:33
    at handleError (C:\LWO\lwo.web\node_modules\lasso\lib\writers\Writer.js:154:32)
    at C:\LWO\lwo.web\node_modules\lasso\lib\writers\Writer.js:171:36
    at CombinedStream.handleError (C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:429:17)
    at emitOne (events.js:82:20)
    at CombinedStream.emit (events.js:169:7)
    at DeferredReadable.onError (C:\LWO\lwo.web\node_modules\lasso\lib\util\CombinedStream.js:23:18)
    at emitOne (events.js:77:13)
Caused by: Error: Error while resolving resource URL for path "C:\LWO\lwo.web\x\fonts\fontawesome-webfont.eot". Error: Error: Error while writing resource "C:\LWO\lwo.web\x\fonts\fontawesome-webfont.eot": 
Error: EPERM: operation not permitted, rename 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.eot.10172.7982' -> 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.eot'
    at Error (native)
    at module.exports (C:\LWO\lwo.web\node_modules\raptor-util\createError.js:7:50)
    at done (C:\LWO\lwo.web\node_modules\lasso\lib\Lasso.js:371:19)
    at done (C:\LWO\lwo.web\node_modules\lasso\lib\writers\Writer.js:193:24)
    at handleError (C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:470:17)
    at C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:479:21
    at handleError (C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:119:13)
    at C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:218:40
    at FSReqWrap.oncomplete (fs.js:82:15)
Caused by: Error: Error while writing resource "C:\LWO\lwo.web\x\fonts\fontawesome-webfont.eot": Error: EPERM: operation not permitted, rename 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.e
ot.10172.7982' -> 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.eot'
    at Error (native)
    at module.exports (C:\LWO\lwo.web\node_modules\raptor-util\createError.js:7:50)
    at done (C:\LWO\lwo.web\node_modules\lasso\lib\writers\Writer.js:193:33)
    at handleError (C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:470:17)
    at C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:479:21
    at handleError (C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:119:13)
    at C:\LWO\lwo.web\node_modules\lasso\lib\writers\file-writer.js:218:40
    at FSReqWrap.oncomplete (fs.js:82:15)
Caused by: Error: EPERM: operation not permitted, rename 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.eot.10172.7982' -> 'C:\LWO\lwo.web\y\root\lwo$1.0.0\x\fonts\fontawesome-webfont.eot'
    at Error (native)

Another simulation is to require Katex (npm install katex) and their css katex\dist\katex.min.css .

patrick-steele-idem commented 8 years ago

Thanks for reporting the problem. I will try to take a look today or tomorrow. Sorry for the delay, but I was out of the office this past week.

alexheb commented 8 years ago

No problem - it's not high priority issue, because the second appearance of eot file could be often removed today -it's backward compatibility for IE 6-8 I think. But above font-face snippet is common pattern.