fonteditor-core icon indicating copy to clipboard operation
fonteditor-core copied to clipboard

Our Node app is frequently getting killed with an npm error

Open kanirajan2530 opened this issue 1 year ago • 2 comments

Description

I encountered an unhandled rejection error in our project, which resulted in Node being terminated. This issue seems to be related to an npm error.

Error Details

abort(ReferenceError: count is not defined) at Error at jsStackTrace (D:\Practice\node_modules\fonteditor-core\woff2\woff2.js:8:22498) at stackTrace (D:\Practice\node_modules\fonteditor-core\woff2\woff2.js:8:22669) at process.abort (D:\Practice\node_modules\fonteditor-core\woff2\woff2.js:8:18310) at process.emit (node:events:514:28) at emit (node:internal/process/promises:149:20) at processPromiseRejections (node:internal/process/promises:283:27) at process.processTicksAndRejections (node:internal/process/task_queues:96:32) (Use node --trace-uncaught ... to show where the exception was thrown)

Node.js v18.17.0

Actual Behaviour

When using the fonteditor-core npm package to decode a WOFF2 font and handle specific Unicode characters, any errors encountered should not terminate the Node.js process. Currently, there is an issue where unhandled rejection errors are causing unexpected behaviour.

Environment

  • Node version: v18.17.0
  • Npm version: 9.6.7

Additional Information

Seems like an issue with woff2.js

fonteditor-core error

kanirajan2530 avatar Jul 20 '24 07:07 kanirajan2530

Could you provide a min reproduce code. You can use child process or worker_threads to handle woff2 conversion, avoid process exiting on error.

kekee000 avatar Aug 01 '24 02:08 kekee000

Ok, Thanks for your update. This code we are using for our project

const { Font, woff2 } =require("fonteditor-core"); const fs = require("fs"); const buffer = fs.readFileSync("../inputs/material.woff2"); woff2.init().then(() => { const font = Font.create(buffer, { type: "woff2", subset: [ 0xeb4e, 0xec17 ], }); const fontObject = font.get(); const writeBuffer = font.write({ type: "woff2", }); const fontFilePath = '../outputs/system_icons.woff2'; fs.writeFileSync(fontFilePath, writeBuffer, {}); });

kanirajan2530 avatar Aug 01 '24 06:08 kanirajan2530