Skip to content

Build your personal knowledge base with Trilium Notes

test(core): bump timeout for scrypt login/password specs under WASM coverage

Elian Dorana825408a01b1
diff --git a/packages/trilium-core/src/routes/api/login.spec.ts b/packages/trilium-core/src/routes/api/login.spec.ts
index a0089131f9..6ede8c3ec2 100644
--- a/packages/trilium-core/src/routes/api/login.spec.ts
+++ b/packages/trilium-core/src/routes/api/login.spec.ts
@@ -5,6 +5,16 @@ import protectedSession from "../../services/protected_session";
import ws from "../../services/ws";
import { CoreApiTester } from "../../test/api_tester";
+// The protected-session login does real scrypt (N=16384) password verification
+// and data-key derivation. Under the browser provider that runs in pure JS
+// (scrypt-js), ~10x slower with V8 coverage instrumentation than Node's native
+// scryptSync — enough to blow the 5s default. Give the standalone (happy-dom)
+// suite a larger timeout; the server suite keeps the strict default.
+const isBrowserRuntime = typeof window !== "undefined";
+if (isBrowserRuntime) {
+ vi.setConfig({ testTimeout: 60000, hookTimeout: 60000 });
+}
+
/**
* Drives the shared core protected-session login routes through
* {@link CoreApiTester} (no Express), so this spec runs under both the node and
diff --git a/packages/trilium-core/src/routes/api/password.spec.ts b/packages/trilium-core/src/routes/api/password.spec.ts
index 0a99909b65..3fbf7e24ed 100644
--- a/packages/trilium-core/src/routes/api/password.spec.ts
+++ b/packages/trilium-core/src/routes/api/password.spec.ts
@@ -4,6 +4,16 @@ import passwordService from "../../services/encryption/password";
import { getSql } from "../../services/sql/index";
import { CoreApiTester } from "../../test/api_tester";
+// Changing/setting a password does real scrypt (N=16384) hashing + data-key
+// re-derivation. Under the browser provider that runs in pure JS (scrypt-js),
+// ~10x slower with V8 coverage instrumentation than Node's native scryptSync —
+// enough to blow the 5s default. Give the standalone (happy-dom) suite a larger
+// timeout; the server suite keeps the strict default.
+const isBrowserRuntime = typeof window !== "undefined";
+if (isBrowserRuntime) {
+ vi.setConfig({ testTimeout: 60000, hookTimeout: 60000 });
+}
+
/**
* Drives the shared core password routes through {@link CoreApiTester} (no
* Express), so this spec runs under both the node and standalone (WASM) suites.