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: Method Date.prototype.toString called on incompatible receiver [object Date] #655

Closed
florian-heer opened this issue Jun 2, 2024 · 2 comments

Comments

@florian-heer
Copy link

florian-heer commented Jun 2, 2024

Hi,

in a workflow i am getting the error (2 days ago everything was fine):

7:32:01 AM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[7:32:01 AM] [semantic-release] › ✘  Failed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[7:32:01 AM] [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/.config/yarn/global/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
    at defaultCommitTransform (file:///home/runner/.config/yarn/global/node_modules/conventional-changelog-writer/dist/options.js:23:23)
    at transformCommit (file:///home/runner/.config/yarn/global/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
    at write (file:///home/runner/.config/yarn/global/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/.config/yarn/global/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
    at defaultCommitTransform (file:///home/runner/.config/yarn/global/node_modules/conventional-changelog-writer/dist/options.js:23:23)
    at transformCommit (file:///home/runner/.config/yarn/global/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
    at write (file:///home/runner/.config/yarn/global/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'
}

Im using the following setup of semantic-release.
Versions:

yarn global add semantic-release \
@semantic-release/commit-analyzer \
@semantic-release/release-notes-generator \
@semantic-release/npm \
@semantic-release/github \
@semantic-release/changelog \
@semantic-release/git \
conventional-changelog-conventionalcommits@7.0.2 \
semantic-release-export-data

Config:

const config = {
  branches: [{ name: 'main', prerelease: false }],
  tagFormat: '${version}',
  repositoryUrl: '...',
  debug: true,
  plugins: [
    [
      '@semantic-release/commit-analyzer',
      {
        releaseRules: [
          { type: 'fix', release: 'patch' },
          { type: 'refactor', release: 'patch' },
          { type: 'feat', release: 'minor' },
          { type: 'breaking', release: 'major' },
        ],
      },
    ],
    [
      '@semantic-release/release-notes-generator',
      {
        preset: 'conventionalcommits',
        presetConfig: {
          types: [
            { type: 'build', section: 'Build System', hidden: false },
            { type: 'chore', section: 'Build System', hidden: false },
            { type: 'ci', section: 'Continuous Integration', hidden: false },
            { type: 'docs', section: 'Documentation', hidden: false },
            { type: 'feat', section: 'Features', hidden: false },
            { type: 'fix', section: 'Bug Fixes', hidden: false },
            { type: 'perf', section: 'Performance Improvements', hidden: false },
            { type: 'refactor', section: 'Code Refactoring', hidden: false },
            { type: 'style', section: 'Styles', hidden: false },
            { type: 'test', section: 'Tests', hidden: false },
          ],
        },
        writerOpts: {
          commitsSort: ['subject', 'scope'],
        },
      },
    ],
    '@semantic-release/npm',
    '@semantic-release/github',
    '@semantic-release/changelog',
    {
      changelogFile: 'CHANGELOG.md',
    },
    '@semantic-release/git',
    {
      assets: ['package.json', `CHANGELOG.md`],
      message:
        'chore(release): ${mainRelease.version} [skip ci]\n\n${mainRelease.notes}',
    },
  ],
}
@florian-heer
Copy link
Author

After removing the version (@7.0.2) of conventional-changelog-conventionalcommits the workflow is working again. Set the version to 7.0.2 was a quick fix, since something was broken in the version 8.0.0

@travi
Copy link
Member

travi commented Jun 7, 2024

After removing the version (@7.0.2) of conventional-changelog-conventionalcommits the workflow is working again. Set the version to 7.0.2 was a quick fix, since something was broken in the version 8.0.0

please reconsider unpinning the version. you are correct that v7.0.2 is no longer the correct version to pin, but pinning v8 (just pinning the major version should be fine) can protect you from running into similar problems for the next release of breaking changes

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

No branches or pull requests

2 participants