mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 07:07:33 +00:00
fix(core): throwing in tcpSend onData callback would crash (#705)
* fix(core): throwing in tcpSend onData callback would crash * docs: update changelog for these changes
This commit is contained in:
parent
49093f0b0f
commit
da78c84c03
2 changed files with 8 additions and 2 deletions
|
|
@ -6,6 +6,7 @@
|
|||
* Feat: 7 Days to Die get more optional Telnet data via an option (#693)
|
||||
* Feat: Update OpenTTD (By @mwkaicz #695)
|
||||
* Fix: Skip non-response packets in protocol-battlefield (By @cetteup #704)
|
||||
* Fix: throwing in tcpSend onData callback would crash gamedig (#705, thanks @cetteup)
|
||||
|
||||
## 5.3.0
|
||||
* Docs: Arma Reforger query setup note (#670, thanks @xCausxn)
|
||||
|
|
|
|||
|
|
@ -222,11 +222,16 @@ export default class Core extends EventEmitter {
|
|||
async tcpSend (socket, buffer, ondata) {
|
||||
let timeout
|
||||
try {
|
||||
const promise = new Promise((resolve, _reject) => {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
let received = Buffer.from([])
|
||||
const onData = (data) => {
|
||||
received = Buffer.concat([received, data])
|
||||
const result = ondata(received)
|
||||
let result
|
||||
try {
|
||||
result = ondata(received)
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
if (result !== undefined) {
|
||||
socket.removeListener('data', onData)
|
||||
resolve(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue