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