Automattic/node-canvas

an error "UnhandledPromiseRejectionWarning: Error: EILSEQ, Illegal byte sequence" occurred when using Japanese characters on loadImage function

Aperta

#1802 aperta il 15 mag 2021

 (2 commenti) (0 reazioni) (0 assegnatari)JavaScript (1195 fork)batch import
BugHelp wanted

Metriche repository

Star
 (10.688 stelle)
Metriche merge PR
 (Merge medio 34g 18h) (2 PR mergiate in 30 g)

Descrizione

Issue or Feature

As the title suggests.

Steps to Reproduce

const { loadImage } = require('canvas')
const myimg = loadImage('あ.jpg')

The results are as follows:

(node:23792) UnhandledPromiseRejectionWarning: Error: EILSEQ, Illegal byte sequence 'あ.jpg'
    at setSource (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\lib\image.js:91:13)
    at Image.set (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\lib\image.js:62:9)
    at C:\Users\user\WebstormProjects\myProject\node_modules\canvas\index.js:34:15
    at new Promise (<anonymous>)
    at loadImage (C:\Users\user\WebstormProjects\myProject\node_modules\canvas\index.js:23:10)
    at Object.<anonymous> (C:\Users\user\WebstormProjects\myProject\main.js:2:15)
    at Module._compile (internal/modules/cjs/loader.js:1236:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
    at Module.load (internal/modules/cjs/loader.js:1085:32)
    at Function.Module._load (internal/modules/cjs/loader.js:950:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:23792) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23792) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

So is it not supported using Japanese or other languages for a file name? I confirmed It can be reproduced when using Korean or Chinese characters too. thanks.

Your Environment

  • Version of node-canvas : canvas@2.7.0
  • Environment : node v14.6.0, Windows 10 Pro x64 version 20H2

Guida contributor