mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-12 07:43:10 +10:00
fix(printer): increase timeout to 15s
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { t } from "@lingui/macro";
|
||||
import { deepSearchAndParseDates } from "@reactive-resume/utils";
|
||||
import { deepSearchAndParseDates, ErrorMessage } from "@reactive-resume/utils";
|
||||
import _axios from "axios";
|
||||
import createAuthRefreshInterceptor from "axios-auth-refresh";
|
||||
import { redirect } from "react-router-dom";
|
||||
@ -25,13 +25,16 @@ axios.interceptors.response.use(
|
||||
return { ...response, data: transformedResponse };
|
||||
},
|
||||
(error) => {
|
||||
const message = error.response?.data.message || error.message;
|
||||
const message = error.response?.data.message as ErrorMessage;
|
||||
const description = translateError(message);
|
||||
|
||||
if (description) {
|
||||
toast({
|
||||
variant: "error",
|
||||
title: t`Oops, the server returned an error.`,
|
||||
description: translateError(message),
|
||||
description,
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
},
|
||||
|
||||
@ -41,6 +41,6 @@ export const translateError = (error: ErrorMessage) => {
|
||||
return t`Something went wrong while processing your request. Please try again later or raise an issue on GitHub.`;
|
||||
|
||||
default:
|
||||
return error;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,8 +7,8 @@ export const configSchema = z.object({
|
||||
PORT: z.coerce.number().default(3000),
|
||||
|
||||
// Client Port & URL (only for development environments)
|
||||
__DEV__CLIENT_PORT: z.coerce.number().default(5173),
|
||||
__DEV__CLIENT_URL: z.string().url().default("http://localhost:5173"),
|
||||
__DEV__CLIENT_PORT: z.coerce.number().optional(),
|
||||
__DEV__CLIENT_URL: z.string().url().optional(),
|
||||
|
||||
// URLs
|
||||
PUBLIC_URL: z.string().url(),
|
||||
|
||||
@ -14,7 +14,7 @@ import { Config } from "../config/schema";
|
||||
import { StorageService } from "../storage/storage.service";
|
||||
import { UtilsService } from "../utils/utils.service";
|
||||
|
||||
const PRINTER_TIMEOUT = 10000; // 10 seconds
|
||||
const PRINTER_TIMEOUT = 15000; // 15 seconds
|
||||
|
||||
@Injectable()
|
||||
export class PrinterService {
|
||||
@ -76,9 +76,7 @@ export class PrinterService {
|
||||
async printPreview(resume: ResumeDto) {
|
||||
return this.utils.getCachedOrSet(
|
||||
`user:${resume.userId}:storage:previews:${resume.id}`,
|
||||
async () => {
|
||||
return withTimeout(this.generatePreview(resume), PRINTER_TIMEOUT);
|
||||
},
|
||||
async () => withTimeout(this.generatePreview(resume), PRINTER_TIMEOUT),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -22,8 +22,6 @@ export class TranslationService {
|
||||
) {}
|
||||
|
||||
async fetchLanguages() {
|
||||
const isDevelopment = this.configService.get("NODE_ENV") === "development";
|
||||
|
||||
try {
|
||||
const projectId = this.configService.getOrThrow("CROWDIN_PROJECT_ID");
|
||||
const accessToken = this.configService.getOrThrow("CROWDIN_ACCESS_TOKEN");
|
||||
@ -34,6 +32,7 @@ export class TranslationService {
|
||||
);
|
||||
const { data } = response.data as CrowdinResponse;
|
||||
|
||||
// Add English Locale
|
||||
data.push({
|
||||
data: {
|
||||
language: {
|
||||
@ -46,7 +45,7 @@ export class TranslationService {
|
||||
},
|
||||
});
|
||||
|
||||
if (isDevelopment) {
|
||||
// Add Pseudo Locale
|
||||
data.push({
|
||||
data: {
|
||||
language: {
|
||||
@ -58,7 +57,6 @@ export class TranslationService {
|
||||
translationProgress: 100,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return data.map(({ data }) => {
|
||||
return {
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
export const delay = (time: number) => new Promise((resolve) => setTimeout(resolve, time));
|
||||
|
||||
export const withTimeout = async <T>(promise: Promise<T>, time: number): Promise<T> => {
|
||||
const timeout = new Promise((_, reject) =>
|
||||
setTimeout(() => {
|
||||
reject(new Error(`Operation timed out after ${time} ms.`));
|
||||
}, time),
|
||||
);
|
||||
|
||||
const timeout = new Promise((_, reject) => setTimeout(() => reject, time));
|
||||
return Promise.race([promise, timeout]) as T;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user