Skip to content

Commit

Permalink
chore: addressed PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 committed Nov 22, 2024
1 parent 2a7cc74 commit 9e48a58
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions test/integration/transaction/tracer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { tspl } = require('@matteo.collina/tspl')
const helper = require('../../lib/agent_helper')
const { EventEmitter } = require('events')
const symbols = require('../../../lib/symbols')
const tempRemoveListeners = require('../../lib/temp-remove-listeners')

test.beforeEach((ctx) => {
const agent = helper.instrumentMockedAgent()
Expand Down Expand Up @@ -122,24 +123,12 @@ test('bind + throw', async function testThrows(t) {

test('bind + capture error', async function testThrows(t) {
const { agent, tracer } = t.nr
const listeners = process.listeners('uncaughtException')
process.removeAllListeners('uncaughtException')

t.after(() => {
for (const listener of listeners) {
process.on('uncaughtException', listener)
}
})

tempRemoveListeners({ t, emitter: process, event: 'uncaughtException' })
const error = new Error('oh no!!')
const name = 'some custom transaction name'
const plan = tspl(t, { plan: 8 })

// Need to break out of tap's domain so the error is truly uncaught.
const pin = setTimeout(function () {}, 5000)
helper.runOutOfContext(function () {
clearTimeout(pin)

helper.runInTransaction(agent, inTrans)
})

Expand All @@ -163,11 +152,8 @@ test('bind + capture error', async function testThrows(t) {

function dangerous(segment) {
return tracer.bindFunction(function bound() {
// next tick to avoid tap error handler
process.nextTick(function ohno() {
plan.equal(tracer.getSegment(), segment)
throw error
})
plan.equal(tracer.getSegment(), segment)
throw error
}, segment)
}
await plan.completed
Expand Down

0 comments on commit 9e48a58

Please sign in to comment.