Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit c8fcc13

Browse files
committed
Fixes #148.
1 parent 502255b commit c8fcc13

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/lib/GrpcClient.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ export class GrpcClient extends EventEmitter {
259259
timeNormalisedRequest,
260260
metadata
261261
)
262-
} catch (e) {
263-
this.emit(MiddlewareSignals.Log.Error, e.message)
262+
} catch (error) {
263+
this.emit(MiddlewareSignals.Log.Error, error.message)
264264
this.emit(MiddlewareSignals.Event.Error)
265265
this.setNotReady()
266+
return { error }
266267
}
267268
/**
268269
* Once this gets attached here, it is attached to *all* calls

src/lib/ZBWorkerBase.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export class ZBWorkerBase<
385385
return
386386
}
387387
this.logger.logDebug('Activating Jobs...')
388-
const jobStream = (await this.activateJobs()) as any
388+
const jobStream = await this.activateJobs()
389389
const id = uuid.v4()
390390
const start = Date.now()
391391
this.logger.logDebug(
@@ -399,7 +399,7 @@ export class ZBWorkerBase<
399399
this.jobStreams[id] = jobStream.stream
400400
// This event happens when the server cancels the call after the deadline
401401
// And when it has completed a response with work
402-
jobStream!.stream.on('end', () => {
402+
jobStream.stream.on('end', () => {
403403
this.logger.logDebug(
404404
`Stream ended after ${(Date.now() - start) / 1000} seconds`
405405
)
@@ -417,13 +417,13 @@ export class ZBWorkerBase<
417417
)
418418
}
419419
}
420-
if (jobStream!.atCapacity) {
421-
jobStream!.atCapacity.once(CapacityEvent.Available, () =>
420+
if (jobStream.atCapacity) {
421+
jobStream.atCapacity.once(CapacityEvent.Available, () =>
422422
this.longPollLoop()
423423
)
424424
}
425-
if (jobStream!.error) {
426-
this.logger.logError(jobStream!.error.message)
425+
if (jobStream.error) {
426+
this.logger.logError(jobStream.error.message)
427427
setTimeout(() => this.longPollLoop(), 1000) // @TODO implement backoff
428428
}
429429
}

0 commit comments

Comments
 (0)