release-notes-generator
release-notes-generator copied to clipboard
TypeError: Method Date.prototype.toString called on incompatible receiver [object Date]
I got this error
[5:40:14 PM] [semantic-release] › ✘ Failed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[5:40:14 PM] [semantic-release] › ✘ An error occurred while running semantic-release: TypeError: Method Date.prototype.toString called on incompatible receiver [object Date]
at Proxy.toString (<anonymous>)
at [Symbol.toPrimitive] (<anonymous>)
at new Date (<anonymous>)
at Object.formatDate (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
at defaultCommitTransform (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/options.js:23:23)
at transformCommit (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
at write (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/writers.js:39:28)
at async nextAsync (node:internal/streams/from:182:33) {
pluginName: '@semantic-release/release-notes-generator'
}
TypeError: Method Date.prototype.toString called on incompatible receiver [object Date]
at Proxy.toString (<anonymous>)
at [Symbol.toPrimitive] (<anonymous>)
at new Date (<anonymous>)
at Object.formatDate (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
at defaultCommitTransform (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/options.js:23:23)
at transformCommit (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
at write (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/writers.js:39:28)
at async nextAsync (node:internal/streams/from:182:33) {
pluginName: '@semantic-release/release-notes-generator'
}error Command failed with exit code 1.
when upgrading:
- from
"@semantic-release/release-notes-generator": "13.0.0", - to
"@semantic-release/release-notes-generator": "14.0.0",
my release config looks like this
module.exports = {
branches: ['main'],
plugins: [
[
'@semantic-release/commit-analyzer',
{
releaseRules: [
{ type: 'refactor', release: 'patch' },
{ type: 'docs', scope: 'README', release: 'patch' },
{ type: 'test', release: 'patch' },
{ type: 'style', release: 'patch' },
{ type: 'perf', release: 'patch' },
{ type: 'ci', release: 'patch' },
{ type: 'build', release: 'patch' },
{ type: 'chore', release: 'patch' },
{ type: 'no-release', release: false },
],
parserOpts: {
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'],
},
},
],
[
'@semantic-release/release-notes-generator',
{
preset: 'conventionalcommits',
presetConfig: {
types: [
{ type: 'feat', section: ':sparkles: Features', hidden: false },
{ type: 'fix', section: ':bug: Fixes', hidden: false },
{ type: 'docs', section: ':memo: Documentation', hidden: false },
{ type: 'style', section: ':barber: Code-style', hidden: false },
{ type: 'refactor', section: ':zap: Refactor', hidden: false },
{
type: 'perf',
section: ':fast_forward: Performance',
hidden: false,
},
{
type: 'test',
section: ':white_check_mark: Tests',
hidden: false,
},
{ type: 'ci', section: ':repeat: CI', hidden: false },
{ type: 'chore', section: ':repeat: Chore', hidden: false },
],
},
},
],
['@semantic-release/npm', { npmPublish: false }],
['@semantic-release/github', { successComment: false, failComment: false }],
[
'@semantic-release/changelog',
{ changelogFile: '.github/CHANGELOG.md', changelogTitle: '# Changelog' },
],
[
'@semantic-release/git',
{
assets: ['.github/CHANGELOG.md', 'package.json'],
message: 'chore(release): ${nextRelease.version} [skip ci]',
},
],
],
};
What version of semantic-release are you running? You likely need to upgrade that as well.
Also, you should not need to install the release-notes-generator separately since it is a dependency of semantic-release. You likely have multiple versions installed. Your safest option is to let semantic-release just use the one it includes as a dependency
So I reverted the package version to get it working again. These are the dependencies I have installed:
"semantic-release": "23.0.8",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/commit-analyzer": "12.0.0",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "10.0.6",
"@semantic-release/npm": "12.0.1",
"@semantic-release/release-notes-generator": "13.0.0",
I thought I should have each individually installed based on the docs:
- https://github.com/semantic-release/semantic-release/blob/master/docs/usage/installation.md#local-installation
- https://github.com/semantic-release/release-notes-generator?tab=readme-ov-file#install
I am running into the same error using these versions
[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
@semantic-release/[email protected]
[email protected]
It does work if I also upgrade conventional-changelog-conventionalcommits to version 8. So I am good :D
Looks like https://github.com/conventional-changelog/commitlint/pull/4069 will help us 🤞 which bumps conventional-changelog-conventionalcommits to v8
Perhaps this helps:
The issue I discovered is that conventional-changelog-writer is not able to serialize with JSON.stringify. The reason for this is that all Date objects are corrupt. They are recognized as instance of Date but does not follow the prototype of Date (something like toString or toISOString is not available).
In my project I use a custom conventional changelog and have adjusted the transform method of the writer so that all dates in the commits will be dropped. This is OK for my case, as I do not use this in my templates.
I am using:
"@semantic-release/release-notes-generator": "14.0.1",
"conventional-changelog-writer": "8.0.0", // this is used under the hood
The only difference I could notice is that conventional-changelog has switched to esm modules and the release notes generate is now using import-from-esm instead of import-from
In my specific case this is really challenging because I need to transpile my custom-conventional-changelog to esm and the custom release perset to cjs
confirmed adding "conventional-changelog-conventionalcommits": "8.0.0", resolves the issue
i'm closing this as solved. upgrade to the latest versions of semantic-release and whatever preset you've opted into using. avoid directly depending on semantic-release packages that are already dependencies of semantic-release itself