Skip to content

TypeError: Method Date.prototype.toString called on incompatible receiver #239

Open
@hasezoey

Description

@hasezoey

Describe the bug
This was a known issue in semantic-release it self (semantic-release/semantic-release#3571), but this github action, at least as of 0a51e81 (tag v4.2.0) still depends on [email protected] due to the package-lock.json:

"node_modules/conventional-changelog-writer": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-8.0.0.tgz",

Error:

[10:03:39 AM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[10:03:39 AM] [semantic-release] › ✘  Failed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[10:03:39 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/work/_actions/cycjimmy/semantic-release-action/0a51e81a6baff2acad3ee88f4121c589c73d0f0e/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
    at defaultCommitTransform (file:///home/runner/work/_actions/cycjimmy/semantic-release-action/0a51e81a6baff2acad3ee88f4121c589c73d0f0e/node_modules/conventional-changelog-writer/dist/options.js:23:23)
    at transformCommit (file:///home/runner/work/_actions/cycjimmy/semantic-release-action/0a51e81a6baff2acad3ee88f4121c589c73d0f0e/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
    at write (file:///home/runner/work/_actions/cycjimmy/semantic-release-action/0a51e81a6baff2acad3ee88f4121c589c73d0f0e/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: TypeError: Method Date.prototype.toString called on incompatible receiver [object Date]

Workflow

- name: Semantic Release
  uses: cycjimmy/semantic-release-action@0a51e81a6baff2acad3ee88f4121c589c73d0f0e # v4.2.0
  with:
    # dry_run: true
    # plugins included in semantic-release by default:
    # @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/npm @semantic-release/github
    extra_plugins: |
      @semantic-release/[email protected]
      @semantic-release/[email protected]
      @commitlint/[email protected]
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Before the Workaround

As a workaround, [email protected] can be explicitly installed:

extra_plugins: |
  @semantic-release/[email protected]
  @semantic-release/[email protected]
  @commitlint/[email protected]
  [email protected]

Workaround Workflow file

Expected behavior
No Error to happen.

Additional context
This could be solved by either:

  • not shipping a package-lock.json in the action
  • updating conventional-changelog-writer in the lockfile to 8.0.1 (or explicitly depending on it)
  • waiting for semantic-release to update the dependency requirement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions