Skip to content

Commit

Permalink
Fix: faster exit on timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
cvasseng committed Nov 12, 2024
1 parent fc75980 commit b9bd1ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const initPool = async (config) => {

pool.on('destroySuccess', (eventId, resource) => {
log(4, `[pool] Destroyed a worker with ID ${resource.id}.`);
resource.page = null;
});

const initialResources = [];
Expand Down Expand Up @@ -310,8 +311,9 @@ export const postWork = async (chart, options) => {
if (result instanceof Error) {
// TODO: If the export failed because puppeteer timed out, we need to force kill the worker so we get a new page. That needs to be handled better than this hack.
if (result.message === 'Rasterization timeout') {
workerHandle.page.close();
workerHandle.page = await newPage();
// workerHandle.page.close();
// workerHandle.page = await newPage();
workerHandle.workCount = poolConfig.workLimit + 1;
}

throw new ExportError(
Expand Down
2 changes: 1 addition & 1 deletion lib/server/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const logErrorMiddleware = (error, req, res, next) => {
const returnErrorMiddleware = (error, req, res, next) => {
// Gather all requied information for the response
const { statusCode: stCode, status, message, stack } = error;
const statusCode = stCode || status || 500;
const statusCode = stCode || status || 400;

// Set and return response
res.status(statusCode).json({ statusCode, message, stack });
Expand Down

0 comments on commit b9bd1ed

Please sign in to comment.