Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zeebe): fix waitForReady deadline #151

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ test('Calls the onConnectionError handler if there is no broker and eagerConnect
}, 7000)
}))

test('Sets connected:false if there is no broker and no setting of eagerConnection', () =>
test('Sets connected:undefined if there is no broker and no setting of eagerConnection', () =>
new Promise((done) => {
const zbc2 = new ZeebeGrpcClient({
config: { ZEEBE_ADDRESS: 'localtoast: 267890' },
}) // Broker doesn't exist!!!
setTimeout(async () => {
expect(zbc2.connected).toBe(false)
expect(zbc2.connected).toBe(undefined)
await zbc2.close()
done(null)
}, 5000)
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/zeebe/integration/Client-onReady.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('Does not call the onReady handler if there is no broker', (done) => {
}, 4000)
})

test('Does call the onReady handler if there is a broker and eagerConnection is true', (done) => {
test('Calls the onReady handler if there is a broker and eagerConnection is true', (done) => {
let called = 0
const zbc2 = new ZeebeGrpcClient({
config: { zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_EAGER_CONNECT: true } },
Expand All @@ -35,7 +35,7 @@ test('Does call the onReady handler if there is a broker and eagerConnection is
}, 6000)
})

test('Does set connected to true if there is a broker', (done) => {
test('Sets connected to true if there is a broker', (done) => {
const zbc2 = new ZeebeGrpcClient({
config: { zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_EAGER_CONNECT: true } },
})
Expand All @@ -47,7 +47,7 @@ test('Does set connected to true if there is a broker', (done) => {
}, 6000)
})

test('Does emit the ready event if there is a broker and eagerConnection: true', (done) => {
test('emits the ready event if there is a broker and eagerConnection: true', (done) => {
let called = 0
const zbc2 = new ZeebeGrpcClient({
config: { zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_EAGER_CONNECT: true } },
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/zeebe/integration/Worker-onReady.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ test('Does set connected: true if there is a broker and eagerConnection: true',
}, 7000)
})

test('Does not set connected: true if there is a broker and eagerConnection: false', (done) => {
test('Sets connected: true if there is a broker and eagerConnection: false', (done) => {
const zbc2 = new ZeebeGrpcClient()
setTimeout(async () => {
expect(zbc2.connected).toBe(false)
expect(zbc2.connected).toBe(true)
await zbc2.close()
done()
}, 7000)
Expand Down
3 changes: 2 additions & 1 deletion src/zeebe/lib/GrpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ export class GrpcClient extends EventEmitter {
})
this.listNameMethods = []

this.client.waitForReady(10000, (error) =>
// See https://github.com/camunda/camunda-8-js-sdk/issues/150
this.client.waitForReady(new Date(Date.now() + 10000), (error) =>
error
? this.emit(MiddlewareSignals.Event.Error, error)
: this.emit(MiddlewareSignals.Event.Ready)
Expand Down
Loading