-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Thanks for the awesome library!
I am experimenting with the situation where Fluent becomes unreachable while events are being emitted. I believe sendQueueMaxLimit is the right way to prevent backpressure, but I noticed that dropped entries cause an unhandledPromiseRejection, and I don't see a way to catch the rejection.
Here is a simple reproduction:
const { FluentClient } = require('@fluent-org/logger')
const logger = new FluentClient('testing', {
socket: {
host: 'i-dont-exist.com'
},
sendQueueMaxLimit: {
length: 2,
},
ack: {}
})
const run = async () => {
await Promise.all(Array(3).fill().map(async (_, i) => {
try {
await logger.emit('label', {
hello: i
})
console.log('written!', i)
} catch (err) {
console.error('uh oh!', err.message)
}
}))
}
run()This results in unhandledPromiseRejection: DroppedError. It seems the dropEntry.deferred.reject here is not bubbled up to the caller.
The only resolution I've found is to add the following:
process.on('unhandledRejection', (reason, promise) => {
if (reason instanceof FluentError.DroppedError) return
throw promise
})Is there a correct way to handle this that I am missing?
Metadata
Metadata
Assignees
Labels
No labels