Skip to content

Commit 6665c57

Browse files
committed
Checking if return the promise helps with the timeouts
1 parent 0d6634e commit 6665c57

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

packages/testkit-backend/src/backend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export default class Backend {
2121
this._channel.on('contextOpen', ({ contextId }) => this._controller.openContext(contextId))
2222
this._channel.on('contextClose', ({ contextId }) => this._controller.closeContext(contextId))
2323

24-
this._channel.on('request', ({ contextId, request }) => {
24+
this._channel.on('request', async ({ contextId, request }) => {
2525
try {
26-
this._controller.handle(contextId, request)
26+
await this._controller.handle(contextId, request)
2727
} catch (e) {
2828
this._channel.writeBackendError(contextId, e)
2929
}

packages/testkit-backend/src/controller/interface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class Controller extends EventEmitter {
2424
throw new Error('not implemented')
2525
}
2626

27-
handle(contextId, request) {
27+
async handle(contextId, request) {
2828
throw new Error('not implemented')
2929
}
3030
}

packages/testkit-backend/src/controller/local.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class LocalController extends Controller {
2424
this._contexts.delete(contextId)
2525
}
2626

27-
handle (contextId, { name, data }) {
27+
async handle (contextId, { name, data }) {
2828
if (!this._contexts.has(contextId)) {
2929
throw new Error(`Context ${contextId} does not exist`)
3030
} else if (!(name in this._requestHandlers)) {
@@ -33,7 +33,7 @@ export default class LocalController extends Controller {
3333
throw new Error(`Unknown request: ${name}`)
3434
}
3535

36-
this._requestHandlers[name](this._contexts.get(contextId), data, {
36+
return await this._requestHandlers[name](this._contexts.get(contextId), data, {
3737
writeResponse: (name, data) => this._writeResponse(contextId, name, data),
3838
writeError: (e) => this._writeError(contextId, e),
3939
writeBackendError: (msg) => this._writeBackendError(contextId, msg)

packages/testkit-backend/src/controller/remote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class RemoteController extends Controller {
6666
this._forwardToConnectedClient('contextClose', contextId, { contextId })
6767
}
6868

69-
handle (contextId, request) {
69+
async handle (contextId, request) {
7070
this._forwardToConnectedClient('request', contextId, request)
7171
}
7272

packages/testkit-backend/src/request-handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function ResultNext (context, data, wire) {
167167
if (!("recordIt" in result)) {
168168
result.recordIt = result[Symbol.asyncIterator]()
169169
}
170-
result.recordIt.next().then(({ value, done }) => {
170+
return result.recordIt.next().then(({ value, done }) => {
171171
if (done) {
172172
wire.writeResponse('NullRecord', null)
173173
} else {

0 commit comments

Comments
 (0)