question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

「captureRejections」 property not works in ts-node

See original GitHub issue

Search Terms

I wanna create a eventEmitter with 「captureRejections」 it works in with node.js but not works with ts-node

Expected Behavior

create a eventEmitter instance with able to capture promise rejections with ts-node

Actual Behavior

「captureRejections」property not work with ts-node but works with node

Steps to reproduce the problem

create a file testEvent.js

const { EventEmitter } = require('events');
const ee = new EventEmitter({ captureRejections: true });
console.log(ee)

run

ts-node testEvent.js

check console output

EventEmitter {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  [Symbol(kCapture)]: false
}

[Symbol(kCapture)]: false means 「captureRejections」property is not setted

however, when i use node

run

node testEvent.js

console output

EventEmitter {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  [Symbol(kCapture)]: true
}

[Symbol(kCapture)]: false means 「captureRejections」works

this is so confusing

Minimal reproduction

Specifications

  • ts-node version: v10.4.0

  • node version: v14.15.0

  • TypeScript version: 4.4.4

  • tsconfig.json, if you’re using one: not use

  • Operating system and version: macos 10.15.5 (19F101)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
cspotcodecommented, Jan 4, 2022

I see, you are saying that the node REPL exhibits this bug? Then it is a node bug?

I modified your testEvent.js

// For some reason, the following import triggers this bug.
// If this import is removed, the bug goes away.
require('repl');

const { EventEmitter } = require('events');
const ee = new EventEmitter({ captureRejections: true });
console.log('Event emitter created with captureRejections: true, so `Symbol(kCapture) should be true');
console.log(ee);

And the bug reproduces on the latest node v17.3.0:

❯ node -v
v17.3.0

❯ node ./testEvent.js
Event emitter created with captureRejections: true, so `Symbol(kCapture) should be true
EventEmitter {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  [Symbol(kCapture)]: false
}

0reactions
CMCDragonkaicommented, Jan 16, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

'ts-node' is not recognized as an internal or external command ...
I just encountered a similar issue: on Mac OS --exec ts-node works, on Windows it ...
Read more >
Worker | typescript - v3.7.7
captureRejections. Defined in node_modules/@types/node/events.d.ts:49. Sets or gets the default captureRejection value for all emitters.
Read more >
StreamableRowPromise | couchbase
captureRejections : boolean. Inherited from StreamablePromise.captureRejections. Defined in node_modules/@types/node/events.d.ts:278.
Read more >
Node.js v19.3.0 Documentation
Working with JavaScript values and abstract operations ... node:crypto module methods and properties ... captureRejections; events.
Read more >
neovim - Neovim
Defined in node_modules/@types/node/events.d.ts:273 ... captureRejections: boolean ... Map of process properties, or null if process not found ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found