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

fix(#4917): suppress YAMLException when load js-yaml #4927

Merged
merged 1 commit into from Apr 4, 2022

Conversation

yoshinorin
Copy link
Member

@yoshinorin yoshinorin commented Apr 2, 2022

refs: (#4917)

This PR is just a workaround. Not sure, but I assume this error seems incorrect version resolving of js-yaml.

How to reproduce?

#4917 (comment)

// git clone & checkout
$ git clone https://github.com/hexojs/hexo-generator-category.git
$ git checkout -b issue-4917 f51949900e5dbd15902b45fe4399afb634d54b21
$ git log --oneline
  f519499 (HEAD -> issue-4917) chore(ci): migrate travisCI to GitHubActions (#70)
  f233a38 chore(deps): bump hexo-pagination from 1.0.0 to 2.0.0 (#46)
  fadee1a Upgrade to GitHub-native Dependabot (#45)

// hexo@5.4.0 will be installed
$ npm install

// install hexo@6.1.0
$ npm install hexo@6.1.0

// run test
$ npm run test

> hexo-generator-category@1.0.0 test
> mocha test/index.js

YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object.
    at /mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/node_modules/js-yaml/lib/schema.js:104:13
    at Array.forEach (<anonymous>)
    at Schema.extend (/mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/node_modules/js-yaml/lib/schema.js:102:12)
    at Object.<anonymous> (/mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/lib/plugins/renderer/yaml.js:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)

Dependency tree

Here is the dependency tree after exec How to reproduce? section. Certainly, hexo@6.1.0 depends on js-yaml@4.1.0 and it seems no problem.

$ npm list js-yaml

hexo-generator-category@1.0.0 /mnt/c/Users/username/hexo/hexo-generator-category
├─┬ coveralls@3.1.1
│ └── js-yaml@3.14.1
├─┬ eslint@7.32.0
│ ├─┬ @eslint/eslintrc@0.4.3
│ │ └── js-yaml@3.14.1 deduped
│ └── js-yaml@3.14.1 deduped
├─┬ hexo@6.1.0
│ ├─┬ hexo-front-matter@3.0.0
│ │ └── js-yaml@4.1.0
│ └── js-yaml@4.1.0             <- should be use this. but not actually used???
├─┬ mocha@8.4.0
│ └── js-yaml@4.0.0
└─┬ nyc@15.1.0
  └─┬ @istanbuljs/load-nyc-config@1.1.0
    └── js-yaml@3.14.1 deduped

But, as you know exception occurs when run test. I'm not sure but it seems the require('js-yaml') resolves older than the 4.0.0 version of js-yaml..

I don't know which is the cause hexo, npm, or js-yaml.

Others

I'm going to release a patch version 6.1.1 & 5.4.1 if this PR accepts.

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@github-actions
Copy link

github-actions bot commented Apr 2, 2022

How to test

git clone -b fix/issue-4917 https://github.com/yoshinorin/hexo.git
cd hexo
npm install
npm test

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 98.056% when pulling 610bf40 on yoshinorin:fix/issue-4917 into 8d21027 on hexojs:master.

@yoshinorin yoshinorin merged commit e15ad72 into hexojs:master Apr 4, 2022
@yoshinorin yoshinorin deleted the fix/issue-4917 branch April 4, 2022 12:39
yoshinorin added a commit to yoshinorin/hexo that referenced this pull request Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants