Skip to content

Commit ea3d715

Browse files
chore(core-manager): await log generation on log.download (#4260)
1 parent a1fe7a1 commit ea3d715

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

__tests__/unit/core-manager/server/server-boot-dispose.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,23 @@ import { defaults } from "@packages/core-manager/src/defaults";
1010

1111
let sandbox: Sandbox;
1212
let server: Server;
13-
let pluginsConfiguration = defaults.plugins;
13+
const pluginsConfiguration = defaults.plugins;
1414

15-
let logger = {
15+
const logger = {
1616
info: jest.fn(),
1717
notice: jest.fn(),
1818
error: jest.fn(),
1919
};
2020

2121
let mockStart = jest.fn();
2222
let mockStop = jest.fn();
23+
const mockJsonRPCRoute = {
24+
method: "post",
25+
path: "/",
26+
settings: {
27+
timeout: {},
28+
},
29+
};
2330

2431
jest.mock("@hapi/hapi", () => {
2532
return {
@@ -32,6 +39,7 @@ jest.mock("@hapi/hapi", () => {
3239
register: jest.fn(),
3340
start: jest.fn().mockImplementation(mockStart),
3441
stop: jest.fn().mockImplementation(mockStop),
42+
table: jest.fn().mockReturnValue([mockJsonRPCRoute]),
3543
};
3644
}),
3745
};

packages/core-manager/src/actions/log-download.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class Action implements Actions.Action {
4949
throw new Error("Previous log generation is still in progress.");
5050
}
5151

52-
this.workerManager.generateLog(
52+
await this.workerManager.generateLog(
5353
this.database.getDBFilePath(),
5454
this.database.getSchema(),
5555
this.prepareQueryConditions(params),

packages/core-manager/src/server/server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Container, Contracts, Types } from "@arkecosystem/core-kernel";
2-
import { Server as HapiServer, ServerInjectOptions, ServerInjectResponse } from "@hapi/hapi";
2+
import { Server as HapiServer, ServerInjectOptions, ServerInjectResponse, ServerRoute } from "@hapi/hapi";
33
import { readFileSync } from "fs";
44

55
import { Plugins } from "../contracts";
@@ -26,6 +26,9 @@ export class Server {
2626
this.server.app.app = this.app;
2727

2828
await this.server.register(this.pluginFactory.preparePlugins());
29+
30+
// Disable 2 minute socket timout
31+
this.getRoute("POST", "/").settings.timeout.socket = false;
2932
}
3033

3134
public async register(plugins: any | any[]): Promise<void> {
@@ -68,4 +71,8 @@ export class Server {
6871

6972
return options;
7073
}
74+
75+
private getRoute(method: string, path: string): ServerRoute | undefined {
76+
return this.server.table().find((route) => route.method === method.toLowerCase() && route.path === path);
77+
}
7178
}

0 commit comments

Comments
 (0)