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

TypeError: Cannot read properties of undefined (reading 'InstanceSet') #68

Closed
tjx666 opened this issue May 16, 2023 · 4 comments
Closed
Labels

Comments

@tjx666
Copy link

tjx666 commented May 16, 2023

Describe the bug

with following config:

import { defineConfig } from "vite";
import mkcert from "vite-plugin-mkcert";
import path from "node:path";

// https://vitejs.dev/config/
export default defineConfig({
    server: {
        https: true,
    },
    plugins: [
        mkcert({
            source: "coding",
            savePath: path.resolve(process.cwd(), "node_modules/.cert"),
        }),
    ],
});

when path.resolve(process.cwd(), "node_modules/.cert") is empty, vite will throw error TypeError: Cannot read properties of undefined (reading 'InstanceSet')

Somethings need to note:

  1. this issue only happen mac m1, intel m1 no this issue
  2. this issue only happen when I set source to coding, if I use default source, no this issue
  3. this issue only happen when path.resolve(process.cwd(), "node_modules/.cert") cache not existed

Reproduction

https://github.com/tjx666/vite-plugin-mkcert-issue-m1

git clone [email protected]:tjx666/vite-plugin-mkcert-issue-m1.git
pnpm install
pnpm dev

System Info

Output of npx envinfo --system --npmPackages vite,vite-plugin-mkcert --binaries --browsers:

  System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M1
    Memory: 1.25 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/Library/Caches/fnm_multishells/24796_1684232764095/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/24796_1684232764095/bin/yarn
    npm: 9.5.1 - ~/Library/Caches/fnm_multishells/24796_1684232764095/bin/npm
  Browsers:
    Chrome: 113.0.5672.92
    Safari: 16.4
  npmPackages:
    vite: ^4.3.6 => 4.3.6 
    vite-plugin-mkcert: ^1.15.0 => 1.15.0 

Used package manager: pnpm 8.5.1

Logs

error when starting dev server:
TypeError: Cannot read properties of undefined (reading 'InstanceSet')
    at _CodingSource.getSourceInfo (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite-plugin-mkcert@1.15.0_vite@4.3.6/node_modules/vite-plugin-mkcert/dist/mkcert.mjs:331:47)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Mkcert.getSourceInfo (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite-plugin-mkcert@1.15.0_vite@4.3.6/node_modules/vite-plugin-mkcert/dist/mkcert.mjs:551:24)
    at async Mkcert.initMkcert (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite-plugin-mkcert@1.15.0_vite@4.3.6/node_modules/vite-plugin-mkcert/dist/mkcert.mjs:572:24)
    at async Mkcert.init (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite-plugin-mkcert@1.15.0_vite@4.3.6/node_modules/vite-plugin-mkcert/dist/mkcert.mjs:545:7)
    at async config (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite-plugin-mkcert@1.15.0_vite@4.3.6/node_modules/vite-plugin-mkcert/dist/mkcert.mjs:673:7)
    at async runConfigHook (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite@4.3.6/node_modules/vite/dist/node/chunks/dep-a04f07ec.js:64520:25)
    at async resolveConfig (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite@4.3.6/node_modules/vite/dist/node/chunks/dep-a04f07ec.js:64006:14)
    at async _createServer (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite@4.3.6/node_modules/vite/dist/node/chunks/dep-a04f07ec.js:63247:20)
    at async CAC.<anonymous> (file:///Users/yutengjing/code/vite-plugin-mkcert-issue-m1/node_modules/.pnpm/registry.npmmirror.com+vite@4.3.6/node_modules/vite/dist/node/cli.js:733:24)ELIFECYCLECommand failed with exit code 1.

@lvlingjie
Copy link

same error, how tor resolve it ?

@liuweiGL
Copy link
Owner

liuweiGL commented Jun 27, 2023

Cannot read properties of undefined (reading 'InstanceSet') 这个错误是 coding.net 接口返回值为空导致的,但是我本地测试是好的没法重现。

const version = VersionData.Response.Data.InstanceSet[0]?.Version

@tjx666
Copy link
Author

tjx666 commented Jun 27, 2023

1.14.0 版本是没问题的

github-actions bot pushed a commit that referenced this issue Jun 28, 2023
# [1.16.0](v1.15.0...v1.16.0) (2023-06-28)

### Features

* Support more platforms and architectures ([0cb9571](0cb9571)), closes [#68](#68)
@liuweiGL
Copy link
Owner

🎉 This issue has been resolved in version 1.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to skymoonya/rsbuild-plugin-mkcert that referenced this issue Mar 14, 2024
# 1.0.0 (2024-03-14)

### Bug Fixes

* additional path escaping issue [liuweiGL#80](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/80) ([liuweiGL#81](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/81)) ([a3bbe6c](a3bbe6c))
* fix access denied error caused by JAVA_HOME ([f4f7c18](f4f7c18)), closes [liuweiGL#15](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/15)
* fix built assets error ([12a2de4](12a2de4))
* fix import commonjs modules error ([d7bfaa0](d7bfaa0))
* fix npm package not includes built files ([da701ee](da701ee)), closes [liuweiGL#31](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/31)
* fix the error caused by the path containing spaces ([655bfa4](655bfa4)), closes [liuweiGL#17](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/17)
* fix tsc report an type error ([3695e8c](3695e8c))
* fix wrong debug log ([510d381](510d381))
* generated code include vite code ([e5adc6b](e5adc6b)), closes [liuweiGL#47](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/47)
* get warning from esbuild build ([7e4d968](7e4d968))
* Illegal operation in linux ([d299720](d299720)), closes [liuweiGL#63](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/63)
* local hosts not include ips in node18 ([b710399](b710399))
* local path warning only if path isn't found ([liuweiGL#32](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/32)) ([ac7f533](ac7f533))
* mkcert initialization error ([b8e6e96](b8e6e96)), closes [liuweiGL#62](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/62)
* not working if the mkcert in directory with special charaters ([e3a5b63](e3a5b63)), closes [liuweiGL#61](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/61)
* Plugin‘s type definition is not generic ([1d031d1](1d031d1)), closes [liuweiGL#44](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/44)
* **plugin:** fix linux system permission denied ([bc9c93e](bc9c93e)), closes [liuweiGL#7](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/7)
* **plugin:** mkcert binary lost ([liuweiGL#13](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/13)) ([d4a881b](d4a881b))
* preview mode can use https ([liuweiGL#28](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/28)) ([048a8d1](048a8d1))
* rollback required node version ([782ab10](782ab10))
* **script:** fix read config.json error ([bb227c7](bb227c7))
* **script:** fix release workflow wrong ([d0cf9a3](d0cf9a3))
* **script:** 修复发包之前没有构建资源 ([dbd4b76](dbd4b76))
* **script:** 修复获取最新版本号错误 ([d4ce4c7](d4ce4c7))
* the plugin reports mkcert not recognized as an internal or external command when  parentheses in the folder name ([02278c8](02278c8)), closes [liuweiGL#83](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/83)
* typescript 5.0.2 can not resolve typings ([d070319](d070319)), closes [liuweiGL#65](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/65)
* typescript can't correct resolve .d.ts file ([363d66a](363d66a))
* upgrade dependencies, fix vulnerability ([8c2c0b1](8c2c0b1)), closes [liuweiGL#76](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/76)
* vite version range incorrect ([1486c44](1486c44))
* 修复node14不支持replaceAll导致报错的问题 ([liuweiGL#66](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/66)) ([6936de3](6936de3))

### Features

*  allow force to generate certificate ([ce4c4e0](ce4c4e0))
* add `savePath` `keyFileName`  `certFileName` parameters ([b12de07](b12de07)), closes [liuweiGL#56](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/56)
* add log informations ([1f9c356](1f9c356))
* add logger prefix ([bee34ee](bee34ee))
* always include local hosts ([6bab2ec](6bab2ec))
* complete 1.0 version ([b3773a0](b3773a0))
* complete coding.net mirror setting ([f663270](f663270))
* complete the initial version ([6316831](6316831))
* dev downloader ([9c084e2](9c084e2))
* dev mkcert downloader ([ff9b411](ff9b411))
* export BasetSource-class ([liuweiGL#37](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/37)) ([3f25861](3f25861))
* https is enabled by default ([d1b8197](d1b8197))
* **plugin:** add certificate cache ([e07be64](e07be64))
* **plugin:** plugin only works in serve mode ([d471652](d471652))
* **plugin:** 支持自定义域名 ([liuweiGL#11](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/11)) ([fd6f58e](fd6f58e))
* pretty write config.json file ([0a556ab](0a556ab))
* retain the existing ca ([ee85a33](ee85a33)), closes [liuweiGL#59](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/59)
* rsbuild-plugin-mkcert ([6299325](6299325))
* save CA file to savePath ([6b29fe4](6b29fe4)), closes [liuweiGL#58](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/58)
* support MacOS with M2 chip ([liuweiGL#67](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/67)) ([aebfd07](aebfd07))
* Support more platforms and architectures ([0cb9571](0cb9571)), closes [liuweiGL#68](https://github.com/skymoonya/rsbuild-plugin-mkcert/issues/68)
* support read host from server config ([305639b](305639b))
* Upgrade vite to 5.0 ([ac39d72](ac39d72))
* use peerDependence instead of dependence to control vite version ([542f15e](542f15e))
* 适配 v4.3.0 ([a117ed8](a117ed8))
* 适配 vite3.0 ([960ff59](960ff59))

### Performance Improvements

* pretty log formatter ([f75dfd1](f75dfd1))
* upgrade all dependencies ([fd5a8c0](fd5a8c0))
* upgrade dependencies version ([306f844](306f844))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants