Skip to content

Commit

Permalink
fix: disallow floating promises (#704)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Apr 13, 2022
1 parent 2b6441a commit 549647d
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
'no-console': 'error',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'import/no-cycle': 'error',
'import/newline-after-import': ['error', { count: 1 }],
'import/order': [
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/agent/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ export class Agent {
}

for (const transport of this.inboundTransports) {
transport.start(this)
await transport.start(this)
}

for (const transport of this.outboundTransports) {
transport.start(this)
await transport.start(this)
}

// Connect to mediator through provided invitation if provided in config
Expand All @@ -201,10 +201,10 @@ export class Agent {

// Stop transports
for (const transport of this.outboundTransports) {
transport.stop()
await transport.stop()
}
for (const transport of this.inboundTransports) {
transport.stop()
await transport.stop()
}

// close wallet if still initialized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class CredentialService {
// Update record
credentialRecord.proposalMessage = proposalMessage
credentialRecord.credentialAttributes = proposalMessage.credentialProposal?.attributes
this.updateState(credentialRecord, CredentialState.ProposalSent)
await this.updateState(credentialRecord, CredentialState.ProposalSent)

return { message: proposalMessage, credentialRecord }
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/proofs/services/ProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class ProofService {

// Update record
proofRecord.proposalMessage = proposalMessage
this.updateState(proofRecord, ProofState.ProposalSent)
await this.updateState(proofRecord, ProofState.ProposalSent)

return { message: proposalMessage, proofRecord }
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/routing/RecipientModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class RecipientModule {
this.logger.warn(
`Websocket connection to mediator with connectionId '${mediator.connectionId}' is closed, attempting to reconnect...`
)
this.openMediationWebSocket(mediator)
await this.openMediationWebSocket(mediator)
})

await this.openMediationWebSocket(mediator)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/transport/HttpOutboundTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class HttpOutboundTransport implements OutboundTransport {
)
return
}
this.agent.receiveMessage(encryptedMessage)
await this.agent.receiveMessage(encryptedMessage)
} catch (error) {
this.logger.debug('Unable to parse response message')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/transport/WsOutboundTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class WsOutboundTransport implements OutboundTransport {
)
}
this.logger.debug('Payload received from mediator:', payload)
this.agent.receiveMessage(payload)
void this.agent.receiveMessage(payload)
}

private listenOnWebSocketMessages(socket: WebSocket) {
Expand Down
2 changes: 1 addition & 1 deletion samples/mediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ const run = async () => {
})
}

run()
void run()

0 comments on commit 549647d

Please sign in to comment.