vdesjs / vite-plugin-monaco-editor

A vite plugin for the Monaco Editor
MIT License
206 stars 36 forks source link

fix: mkdir done sync to prevent state race condition #20

Closed yarsky-tgz closed 2 years ago

yarsky-tgz commented 2 years ago

We are getting sometimes while building following erroor

ENOENT: no such file or directory, open '/home/runner/work/platform-client/platform-client/dist/monacoeditorwork/editor.worker.bundle.js'
    at Object.openSync (fs.js:497:3)
    at Object.writeFileSync (fs.js:1528:35)
    at Object.writeBundle (/home/runner/work/platform-client/platform-client/node_modules/vite-plugin-monaco-editor/dist/index.js:114:20)
    at /home/runner/work/platform-client/platform-client/node_modules/rollup/dist/shared/rollup.js:22663:25
    at async Promise.all (index 0)
    at async handleGenerateWrite (/home/runner/work/platform-client/platform-client/node_modules/rollup/dist/shared/rollup.js:23452:9)
    at async doBuild (/home/runner/work/platform-client/platform-client/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:43150:20)
    at async build (/home/runner/work/platform-client/platform-client/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42974:16)
    at async CAC.<anonymous> (/home/runner/work/platform-client/platform-client/node_modules/vite/dist/node/cli.js:737:9

It happens because asynchronous fs.mkdir sometimes has not yet created directory, so I've replaced asynchronous fs.mkdir with fs.mkdirSync