Skip to content

Commit

Permalink
chore(core-manager): await log generation on log.download (#4260)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastijankuzner authored Jan 18, 2021
1 parent a1fe7a1 commit ea3d715
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions __tests__/unit/core-manager/server/server-boot-dispose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ import { defaults } from "@packages/core-manager/src/defaults";

let sandbox: Sandbox;
let server: Server;
let pluginsConfiguration = defaults.plugins;
const pluginsConfiguration = defaults.plugins;

let logger = {
const logger = {
info: jest.fn(),
notice: jest.fn(),
error: jest.fn(),
};

let mockStart = jest.fn();
let mockStop = jest.fn();
const mockJsonRPCRoute = {
method: "post",
path: "/",
settings: {
timeout: {},
},
};

jest.mock("@hapi/hapi", () => {
return {
Expand All @@ -32,6 +39,7 @@ jest.mock("@hapi/hapi", () => {
register: jest.fn(),
start: jest.fn().mockImplementation(mockStart),
stop: jest.fn().mockImplementation(mockStop),
table: jest.fn().mockReturnValue([mockJsonRPCRoute]),
};
}),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core-manager/src/actions/log-download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Action implements Actions.Action {
throw new Error("Previous log generation is still in progress.");
}

this.workerManager.generateLog(
await this.workerManager.generateLog(
this.database.getDBFilePath(),
this.database.getSchema(),
this.prepareQueryConditions(params),
Expand Down
9 changes: 8 additions & 1 deletion packages/core-manager/src/server/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container, Contracts, Types } from "@arkecosystem/core-kernel";
import { Server as HapiServer, ServerInjectOptions, ServerInjectResponse } from "@hapi/hapi";
import { Server as HapiServer, ServerInjectOptions, ServerInjectResponse, ServerRoute } from "@hapi/hapi";
import { readFileSync } from "fs";

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

await this.server.register(this.pluginFactory.preparePlugins());

// Disable 2 minute socket timout
this.getRoute("POST", "/").settings.timeout.socket = false;
}

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

return options;
}

private getRoute(method: string, path: string): ServerRoute | undefined {
return this.server.table().find((route) => route.method === method.toLowerCase() && route.path === path);
}
}

0 comments on commit ea3d715

Please sign in to comment.