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

Strange error with vite@beta on every other build in Yarn PnP with a nested publicDir #8897

Closed
7 tasks done
IgnusG opened this issue Jul 3, 2022 · 5 comments
Closed
7 tasks done
Labels
bug: upstream Bug in a dependency of Vite

Comments

@IgnusG
Copy link

IgnusG commented Jul 3, 2022

Describe the bug

When publicDir is set (which should copy over its contents to the build directory) and we nest its files at least 3 levels deep (public/some/folder/public-asset.all), an error occurs every other build with yarn PnP enabled:

The "path" argument must be of type string. Received an instance of Buffer
error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
    at new NodeError (node:internal/errors:388:5)
    at validateString (node:internal/validators:114:11)
    at Object.isAbsolute (node:path:1157:5)
    at VirtualFS.mapToBase (/repro-vite-yarn-bug/.pnp.cjs:4308:24)
    at VirtualFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:39)
    at PosixFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24)
    at URLFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24)
    at _rmdirSync (node:internal/fs/rimraf:260:21)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9

Reproduction

https://github.com/IgnusG/repro-vite-yarn-bug

System Info

System:
    OS: Linux 5.10 Arch Linux
    CPU: (16) x64 Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz
    Memory: 28.93 GB / 31.23 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.4.0 - ~/.asdf/shims/node
    Yarn: 3.2.1 - ~/.asdf/shims/yarn
    npm: 8.7.0 - ~/.asdf/shims/npm

Used Package Manager

yarn

Logs

Click to expand!
  vite:config bundled config file loaded in 38.84ms +0ms
  vite:config using resolved config: {
  vite:config   publicDir: '/oss/repro-vite-yarn-bug/public',
  vite:config   build: {
  vite:config     target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: false,
  vite:config     cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: { formats: [Array], entry: './lib/index.ts' },
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   optimizeDeps: { force: undefined, esbuildOptions: { preserveSymlinks: undefined } },
  vite:config   configFile: '/repro-vite-yarn-bug/vite.config.ts',
  vite:config   configFileDependencies: [ '/repro-vite-yarn-bug/vite.config.ts' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     optimizeDeps: { force: undefined },
  vite:config     build: {}
  vite:config   },
  vite:config   root: '/repro-vite-yarn-bug',
  vite:config   base: '/',
  vite:config   resolve: { alias: [ [Object], [Object] ] },
  vite:config   cacheDir: '/repro-vite-yarn-bug/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   ssr: undefined,
  vite:config   isWorker: false,
  vite:config   mainConfig: null,
  vite:config   isProduction: true,
  vite:config   plugins: [
  vite:config     'vite:build-metadata',
  vite:config     'alias',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:optimized-deps-build',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm-helper',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:wasm-fallback',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:watch-package-data',
  vite:config     'vite:data-uri',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:dynamic-import-vars',
  vite:config     'vite:import-glob',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     middlewareMode: false,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   },
  vite:config   appType: 'spa',
  vite:config   experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false }
  vite:config } +10ms
vite v3.0.0-beta.5 building for production...
✓ 1 modules transformed.
The "path" argument must be of type string. Received an instance of Buffer
error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
    at new NodeError (node:internal/errors:388:5)
    at validateString (node:internal/validators:114:11)
    at Object.isAbsolute (node:path:1157:5)
    at VirtualFS.mapToBase (/repro-vite-yarn-bug/.pnp.cjs:4308:24)
    at VirtualFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:39)
    at PosixFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24)
    at URLFS.rmdirSync (/repro-vite-yarn-bug/.pnp.cjs:4157:24)
    at _rmdirSync (node:internal/fs/rimraf:260:21)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9

Validations

Since rimraf is mentioned in the error this might be an error in its implementation, I'm not sure how vite uses it though

@sapphi-red
Copy link
Member

sapphi-red commented Jul 3, 2022

I was not able to reproduce it on both Windows and WSL (both yarn v3.2.1).

@sapphi-red sapphi-red added the cannot reproduce The bug cannot be reproduced label Jul 3, 2022
@IgnusG
Copy link
Author

IgnusG commented Jul 3, 2022

I was not able to reproduce it on both Windows and WSL (both yarn v3.2.1).

Hey @sapphi-red thanks for trying it out, have you used the repo I've linked to? That's strange, this is what I see running it on WSL:

yarn-vite-rimraf-error

@sapphi-red sapphi-red removed the cannot reproduce The bug cannot be reproduced label Jul 3, 2022
@sapphi-red
Copy link
Member

Yes I did use your repo.

I was not able to reproduce with node 16.15.0. But I was able to reproduce with node 18.3.0.
I think this is a bug in yarn or node.

@sapphi-red
Copy link
Member

This one seems to be similar yarnpkg/berry#1818.
Closing as it is likely a bug in yarn.

@IgnusG
Copy link
Author

IgnusG commented Jul 3, 2022

This one seems to be similar yarnpkg/berry#1818. Closing as it is likely a bug in yarn.

Thanks for the link! I'll keep a track of that issue

@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite
Projects
None yet
Development

No branches or pull requests

2 participants