Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_UNHANDLED_ERROR #65

Open
patilanz opened this issue Jan 29, 2023 · 1 comment
Open

ERR_UNHANDLED_ERROR #65

patilanz opened this issue Jan 29, 2023 · 1 comment

Comments

@patilanz
Copy link

patilanz commented Jan 29, 2023

I'm working on Windows and I'm using it like this:

export const logger = pino({
  transport: {
    target:path.join(__dirname, 'pinoTransport.ts')
  }
});

// --- pinoTransports.ts ---
import build from 'pino-abstract-transport';
import {saveLog} from "./LogController";

export default function () {
  return build(function (source){
    source.on('data', obj => {
      console.log(obj);
      if(globalThis.is_prod)saveLog(obj);
    });
  }, {
    parseLine: line => {
      try {
        return JSON.parse(line);
      }catch(_){
        return {message: line};
      }
    }
  })
}

It was working perfectly until it didn't. The errors are not clear:

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
  diagnosticCodes: [
    7022, 7006, 2695,
    7006, 7006, 7017,
    2695, 7006
  ]
})
    at new NodeError (node:internal/errors:363:5)
    at ThreadStream.emit (node:events:354:17)
    at destroy (D:\Programming\proyects\server\node_modules\thread-stream\index.js:349:12)
    at Worker.onWorkerMessage (D:\Programming\proyects\server\node_modules\thread-stream\index.js:164:7)
    at Worker.emit (node:events:365:28)
    at MessagePort.<anonymous> (node:internal/worker:241:53)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:461:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)
    at Worker.[kOnExit] (node:internal/worker:273:5)
    at Worker.<computed>.onexit (node:internal/worker:207:20) {
  code: 'ERR_UNHANDLED_ERROR',
  context: {
    diagnosticCodes: [
      7022, 7006, 2695,
      7006, 7006, 7017,
      2695, 7006
    ]
  }
}

pinojs github remarks this:

Running transports TypeScript code on TS-Node seems to be problematic on Windows systems, there's no official support for that yet.

If I change the file name to .js: pinoTransport.js it works, but before that it was also working on .ts

I'm using ts-node-dev this may be a problem. Any ideas?

@mcollina
Copy link
Member

I don't know, it might well be a ts-node-dev issue!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants