datalust / seq-logging

A Node.js client for the Seq HTTP ingestion API
Apache License 2.0
25 stars 15 forks source link

Error when trying to run script TypeError: SafeGlobalBlob is not a constructor at Object. #68

Closed savva312 closed 1 year ago

savva312 commented 1 year ago

Hello i am getting the following error while trying to run a script with seq-logging attached

seq_logger.js:9 const HEADER_FOOTER_BYTES = (new SafeGlobalBlob([HEADER])).size + (new SafeGlobalBlob([FOOTER])).size; ^
TypeError: SafeGlobalBlob is not a constructor at Object.<anonymous> (node_modules\seq-logging\seq_logger.js:9:30) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Object.require.extensions.<computed> [as .js] (\node_modules\ts-node\src\index.ts:1608:43) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.<anonymous> (node_modules\seq-logging\index.js:3:14) at Module._compile (internal/modules/cjs/loader.js:1063:30)
printFatalErrorUponExit                                 source-map-support.js:726
process.emit.sharedData.processEmitHook.installedValue  source-map-support.js:753
exit                                                    per_thread.js:169
process.emit.sharedData.processEmitHook.installedValue  source-map-support.js:750
(anonymous function)                                    execution.js:163

I have no idea what is this and google is not helping. Any idea how tor resolve this?

liammclennan commented 1 year ago

Hi @savva312,

seq-logging is not usually used directly. Have you considered using winston-seq, pino-seq or one of the others?

SafeGlobalBlob is defined here https://github.com/datalust/seq-logging/blob/dev/seq_logger.js#L3 as either the global Blob function or the buffer module so it seems that you have neither of those.

savva312 commented 1 year ago

hey thanks for the reply

am using 'winston-seq' actually but since the error was coming from this i posted the error here if i need to post it in winston-seq package then no problem please let me know and i will close this

this is how i used it based on the docs

import winston from "winston";
import {SeqTransport} from "@datalust/winston-seq";

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.combine(  /* This is required to get errors to log with stack traces. See https://github.com/winstonjs/winston/issues/1498 */
    winston.format.errors({ stack: true }),
    winston.format.json(),
  ),
  defaultMeta: { /* application: 'your-app-name' */ },
  transports: [
    new winston.transports.Console({
      format: winston.format.simple(),
    }),
    new SeqTransport({
      serverUrl: "https://your-seq-server:5341",
      apiKey: "your-api-key",
      onError: (e => { console.error(e) }),
      handleExceptions: true,
      handleRejections: true,
    })
  ]
});
liammclennan commented 1 year ago

Which version of node are you running this on?

savva312 commented 1 year ago
Node: v14.16.0
"winston": "^3.8.2"
"@datalust/winston-seq": "^2.0.0",
liammclennan commented 1 year ago

The version of Node is the problem. Blob was not added until 14.18.

savva312 commented 1 year ago

Thank you so much for this.Saved me a lot of time!