Skip to content

Error [ERR_INTERNAL_ASSERTION]: TypeError: Method height called on incompatible receiver #<Canvas> #39866

@lynn2910

Description

@lynn2910

Version

v16.7.0

Platform

Microsoft Windows NT 10.0.19043.0 x64

Subsystem

No response

What steps will reproduce the bug?

First, i have start a PowerShell terminal in visual studio code.

After, i run the command "npm i canvas" and i have this error from the command :

node:internal/errors:464
    ErrorCaptureStackTrace(err);

How often does it reproduce? Is there a required condition?

This error occurs as soon as I require the "canvas" module, but only with this module.

What is the expected behavior?

I should receive this when requesting the module :

{
  Canvas: [Function],
  Context2d: [Function],
  CanvasRenderingContext2D: [Function],
  CanvasGradient: [Function],
  CanvasPattern: [Function],
  Image: [Function],
  ImageData: [Function],
  PNGStream: [Function],
  PDFStream: [Function],
  JPEGStream: [Function],
  DOMMatrix: [Function],
  DOMPoint: [Function],
  registerFont: [Function],
  parseFont: [Function],
  createCanvas: [Function],
  createImageData: [Function],
  loadImage: [Function],
  backends: [Object],
  version: '2.8.0',
  cairoVersion: '1.17.4',
  jpegVersion: '8',
  gifVersion: '5.2.1',
  freetypeVersion: '2.10.4',
  rsvgVersion: '2.50.3',
  averageColor: [AsyncFunction]
}

What do you see instead?

I see this error :

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_INTERNAL_ASSERTION]: Error [ERR_INTERNAL_ASSERTION]: Error [ERR_INTERNAL_ASSERTION]: TypeError: Method height called on incompatible receiver #<Canvas>
    at getOwnPropertyDescriptor (<anonymous>)
    at formatProperty (node:internal/util/inspect:1674:18)
    at formatRaw (node:internal/util/inspect:1004:9)
    at formatValue (node:internal/util/inspect:791:10)
    at formatProperty (node:internal/util/inspect:1679:11)
    at formatRaw (node:internal/util/inspect:1004:9)
    at formatValue (node:internal/util/inspect:791:10)
    at formatProperty (node:internal/util/inspect:1679:11)
    at formatRaw (node:internal/util/inspect:1004:9)
    at formatValue (node:internal/util/inspect:791:10)
    at Object.inspect (node:internal/util/inspect:338:10)
    at msgResponse (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:42:108)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at new NodeError (node:internal/errors:371:5)
    at Function.fail (node:internal/assert:20:9)
    at handleMaxCallStackSize (node:internal/util/inspect:1368:10)
    at formatRaw (node:internal/util/inspect:1011:12)
    at formatValue (node:internal/util/inspect:791:10)
    at formatRaw (node:internal/util/inspect:1004:9)
    at formatProperty (node:internal/util/inspect:1679:11)
    at formatRaw (node:internal/util/inspect:1004:9)
    at formatValue (node:internal/util/inspect:791:10)
    at Object.inspect (node:internal/util/inspect:338:10)
    at getGoodLength (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:31:65)
    at msgResponse (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:42:108)
    at Object.exe (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:59:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at new NodeError (node:internal/errors:371:5)
    at Function.fail (node:internal/assert:20:9)
    at handleMaxCallStackSize (node:internal/util/inspect:1368:10)
    at formatRaw (node:internal/util/inspect:1011:12)
    at formatValue (node:internal/util/inspect:791:10)
    at formatProperty (node:internal/util/inspect:1679:11)
    at formatRaw (node:internal/util/inspect:1004:9)
    at formatValue (node:internal/util/inspect:791:10)
    at Object.inspect (node:internal/util/inspect:338:10)
    at getGoodLength (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:31:65)
    at msgResponse (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:42:108)
    at Object.exe (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:59:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at new NodeError (node:internal/errors:371:5)
    at Function.fail (node:internal/assert:20:9)
    at handleMaxCallStackSize (node:internal/util/inspect:1368:10)
    at formatRaw (node:internal/util/inspect:1011:12)
    at formatValue (node:internal/util/inspect:791:10)
    at Object.inspect (node:internal/util/inspect:338:10)
    at getGoodLength (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:31:65)
    at msgResponse (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:42:108)
    at Object.exe (C:\Users\CEDRIC2005\code\eden\LanaPUBLIC\exe\cmd\dev\eval.js:59:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_INTERNAL_ASSERTION'
}

Additional information

No response

Edit :

I see the require response with require("util").inspect(data).
But if i use the method JSON.stringify(data) or call a string after, no error occured.

// ENTRIES
JSON.stringify(require("canvas"), null, 2)

// OUTPUT
{
  "backends": {},
  "version": "2.8.0",
  "cairoVersion": "1.17.4",
  "jpegVersion": "8",
  "gifVersion": "5.2.1",
  "freetypeVersion": "2.10.4",
  "rsvgVersion": "2.50.3"
}

or

// ENTRIES
require("canvas"); "hello"

// OUTPUT
"hello"

this code is executed from the method eval

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions