Skip to content

Commit

Permalink
fix: include message with peptalk fail timer
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkpunkd committed Dec 17, 2019
1 parent 242a31f commit bf2113d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/peptalk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@ class PepTalk extends EventEmitter implements PepTalkClient, PepTalkJS {
try { this.emit('error', error) } catch (err) { /* Allow emit with no listeners. */ }
}

private failTimer (c: number): Promise<PepResponse> {
private failTimer (c: number, message: string): Promise<PepResponse> {
return new Promise((_resolve, reject) => {
setTimeout(() => {
reject(new Error(`Parallel promise to send message ${c} did not resolve in time.`))
reject(new Error(`Parallel promise to send message ${c} did not resolve in time. Message: ${message}`))
}, this.timeout)
})
}
Expand Down Expand Up @@ -557,7 +557,7 @@ class PepTalk extends EventEmitter implements PepTalkClient, PepTalkJS {
async send (message: string): Promise<PepResponse> {
let c = this.counter++
return Promise.race([
this.failTimer(c),
this.failTimer(c, message),
new Promise((resolve: (res: PepResponse) => void, reject: (reason?: any) => void) => {
this.ws.then(s => {
if (s === null) {
Expand Down

0 comments on commit bf2113d

Please sign in to comment.