v1.8.0: warehouse module (16 commits), docházka mzda model, leave_type=holiday removal, api.ts race fix
Highlights: - Warehouse module: receipts, issues, reservations, inventory, reports, dashboard, master data (categories, suppliers, locations), FIFO service, integration tests - Docházka: mzda PDF counting model (Odpracováno / Vč. svátků / Přesčas / Svátek / So/Ne / Noc) with Czech weekday names and decimal hours - AttendanceAdmin/AttendanceHistory KPI cards unified to mzda formula with fund bar colored by delta, badges for Práce/Dov/Nem/Sv/Nep - Remove leave_type=holiday entirely (auto-computed from Czech public holidays) - Allow multiple work shifts per day (overlap detection only) - Pre-flight refresh in api.ts eliminates spurious 401s on fresh page loads - Prisma: company_settings gets 6 nullable columns for warehouse numbering (PRI/VYD/INV prefixes, default patterns); migration seeds defaults
This commit is contained in:
@@ -41,19 +41,32 @@ async function getBrowser(): Promise<Browser> {
|
||||
export async function htmlToPdf(html: string): Promise<Buffer> {
|
||||
const b = await getBrowser();
|
||||
const page = await b.newPage();
|
||||
// Per-request timeouts so one stuck render (e.g. image tag pointing at a
|
||||
// hung host) cannot starve every subsequent PDF request. networkidle0 is
|
||||
// intentionally NOT used — it waits for 500ms of zero network connections
|
||||
// and is the original source of the indefinite-hang bug.
|
||||
try {
|
||||
await page.setContent(html, { waitUntil: "networkidle0" });
|
||||
await page.setContent(html, {
|
||||
waitUntil: "domcontentloaded",
|
||||
timeout: 10_000,
|
||||
});
|
||||
const pdf = await page.pdf({
|
||||
format: "A4",
|
||||
printBackground: true,
|
||||
margin: { top: "10mm", bottom: "10mm", left: "10mm", right: "10mm" },
|
||||
timeout: 15_000,
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
} finally {
|
||||
try {
|
||||
await page.close();
|
||||
} catch {
|
||||
await closeBrowser();
|
||||
// If a stuck page won't close, only close the whole browser if it
|
||||
// is actually disconnected — otherwise we just spent 1-2s relaunching
|
||||
// Chromium on every subsequent PDF request.
|
||||
if (!browser?.connected) {
|
||||
await closeBrowser();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user