Local Netlify Plugin fails: Error: function () { [native code] } could not be cloned

Hello!

I created a local netlify plugin at tools/netlify-plugin-percy-test/index.js:

const { Octokit } = require("@octokit/core");

module.exports = {
  async onSuccess({ netlifyConfig, inputs }) {
    const {
      COMMIT_REF: ref,
      DEPLOY_PRIME_URL: origin,
      GITHUB_PAT: auth,
    } = netlifyConfig.build.environment ?? {}

    const { owner, repository, workflowId } = inputs;

    const octokit = new Octokit({ auth });

    console.log({ owner, repository, origin, ref, workflowId });

    await octokit.request('POST /repos/{owner}/{repository}/actions/workflows/{workflowId}/dispatches', {
      owner,
      ref,
      repository,
      workflowId,
      inputs: {
        origin,
      }
    });
  },
}

with this manifest.yml

name: netlify-plugin-percy-test
inputs:
  - name: owner
    description: Github repository owner (scope). e.g. for `https://github.com/actions/netlify`, the `owner` is `"actions"`
  - name: repository
    description: Github repository name. e.g. for `https://github.com/actions/netlify`, the `repository` is `"netlify"`
  - name: workflowId
    description: Name of the workflow file e.g. `"visual-regression.yml"` or the workflow id number e.g. `42`

and this netlify.toml

[build]
  command = "npm run build"

[[redirects]]
  from = "/demo/*"
  to = "/demo/index.html"
  status = 200

[[plugins]]
  package = "/tools/netlify-plugin-percy-test"

  [plugins.inputs]
    owner = "patternfly"
    repository = "patternfly-elements"
    workflowId = "visual-regression.yml"

And the result of running my build was the following:

2:20:29 PM: ────────────────────────────────────────────────────────────────
2:20:29 PM:   Plugin "/tools/netlify-plugin-percy-test" internal error      
2:20:29 PM: ────────────────────────────────────────────────────────────────
2:20:29 PM: ​
2:20:29 PM:   Error message
2:20:29 PM:   Error: function () { [native code] } could not be cloned.
2:20:29 PM: ​
2:20:29 PM:   Plugin details
2:20:29 PM:   Package:        /tools/netlify-plugin-percy-test
2:20:29 PM:   Version:        0.0.1
2:20:29 PM: ​
2:20:29 PM:   Error location
2:20:29 PM:   In "onSuccess" event in "/tools/netlify-plugin-percy-test" from netlify.toml
2:20:29 PM:       at writeChannelMessage (node:internal/child_process/serialization:82:9)
2:20:29 PM:       at process.target._send (node:internal/child_process:819:17)
2:20:29 PM:       at process.target.send (node:internal/child_process:719:19)
2:20:29 PM:       at node:internal/util:360:7
2:20:29 PM:       at new Promise (<anonymous>)
2:20:29 PM:       at bound  (node:internal/util:346:12)
2:20:29 PM:       at sendEventToParent (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/ipc.js:123:46)
2:20:29 PM:       at handleError (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/child/error.js:13:9)
2:20:29 PM:       at handleEvent (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/child/main.js:45:11)
2:20:29 PM:       at processTicksAndRejections (node:internal/process/task_queues:96:5)
2:20:29 PM: ​
2:20:29 PM:   Resolved config
2:20:29 PM:   build:
2:20:29 PM:     command: npm run build
2:20:29 PM:     commandOrigin: config
2:20:29 PM:     environment:
2:20:29 PM:       - ELEVENTY_ENV
2:20:29 PM:       - GITHUB_PAT
2:20:29 PM:       - NODE_VERSION
2:20:29 PM:       - REVIEW_ID
2:20:29 PM:     publish: /opt/build/repo/_site
2:20:29 PM:     publishOrigin: ui
2:20:29 PM:   plugins:
2:20:29 PM:     - inputs: {}
2:20:29 PM:       origin: ui
2:20:29 PM:       package: '@netlify/plugin-lighthouse'
2:20:29 PM:     - inputs: {}
2:20:29 PM:       origin: config
2:20:29 PM:       package: /tools/netlify-plugin-percy-test
2:20:29 PM:   redirects:
2:20:29 PM:     - from: /demo/*
      status: 200
      to: /demo/index.html
  redirectsOrigin: config
​

I’m not really sure what’s going on here. Perhaps it’s the console.log call, or something internal to octokit?

Any advice is welcome

Hey @bennypowers,

Could you share a repo for us to reproduce this issue?