mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-06 12:27:44 +00:00
chore: bump better-call (#4441)
This commit is contained in:
@@ -93,42 +93,43 @@ describe("Custom Session Plugin Tests", async () => {
|
|||||||
expect(session.newData).toEqual({ message: "Hello, World!" });
|
expect(session.newData).toEqual({ message: "Hello, World!" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not create memory leaks with multiple plugin instances", async () => {
|
it.skipIf(globalThis.gc == null)(
|
||||||
const initialMemory = process.memoryUsage();
|
"should not create memory leaks with multiple plugin instances",
|
||||||
|
async () => {
|
||||||
|
const initialMemory = process.memoryUsage();
|
||||||
|
|
||||||
const pluginInstances = [];
|
const pluginInstances = [];
|
||||||
const sessionCount = 100;
|
const sessionCount = 100;
|
||||||
|
|
||||||
for (let i = 0; i < sessionCount; i++) {
|
for (let i = 0; i < sessionCount; i++) {
|
||||||
const plugin = customSession(async ({ user, session }) => {
|
const plugin = customSession(async ({ user, session }) => {
|
||||||
return {
|
return {
|
||||||
user: {
|
user: {
|
||||||
...user,
|
...user,
|
||||||
testField: `test-${i}`,
|
testField: `test-${i}`,
|
||||||
},
|
},
|
||||||
session,
|
session,
|
||||||
iteration: i,
|
iteration: i,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
pluginInstances.push(plugin);
|
pluginInstances.push(plugin);
|
||||||
}
|
}
|
||||||
|
// Force garbage collection (only works if Node.js is started with --expose-gc)
|
||||||
|
// @ts-expect-error
|
||||||
|
globalThis.gc();
|
||||||
|
|
||||||
// Force garbage collection if available (in test environment)
|
const afterPluginCreation = process.memoryUsage();
|
||||||
if (global.gc) {
|
|
||||||
global.gc();
|
|
||||||
}
|
|
||||||
|
|
||||||
const afterPluginCreation = process.memoryUsage();
|
const memoryIncrease =
|
||||||
|
afterPluginCreation.heapUsed - initialMemory.heapUsed;
|
||||||
const memoryIncrease =
|
const memoryIncreasePerPlugin = memoryIncrease / sessionCount;
|
||||||
afterPluginCreation.heapUsed - initialMemory.heapUsed;
|
// Each plugin instance should not use more than <5KB of memory
|
||||||
const memoryIncreasePerPlugin = memoryIncrease / sessionCount;
|
// (this is a reasonable threshold that indicates no major memory leak)
|
||||||
// Each plugin instance should not use more than <5KB of memory
|
expect(memoryIncreasePerPlugin).toBeLessThan(5 * 1024);
|
||||||
// (this is a reasonable threshold that indicates no major memory leak)
|
// Verify that plugins are still functional
|
||||||
expect(memoryIncreasePerPlugin).toBeLessThan(5 * 1024);
|
expect(pluginInstances).toHaveLength(sessionCount);
|
||||||
// Verify that plugins are still functional
|
expect(pluginInstances[0].id).toBe("custom-session");
|
||||||
expect(pluginInstances).toHaveLength(sessionCount);
|
expect(pluginInstances[sessionCount - 1].id).toBe("custom-session");
|
||||||
expect(pluginInstances[0].id).toBe("custom-session");
|
},
|
||||||
expect(pluginInstances[sessionCount - 1].id).toBe("custom-session");
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
11
packages/better-auth/vitest.config.ts
Normal file
11
packages/better-auth/vitest.config.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
poolOptions: {
|
||||||
|
forks: {
|
||||||
|
execArgv: ["--expose-gc"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@@ -10,8 +10,8 @@ catalogs:
|
|||||||
specifier: ^1.1.18
|
specifier: ^1.1.18
|
||||||
version: 1.1.18
|
version: 1.1.18
|
||||||
better-call:
|
better-call:
|
||||||
specifier: 1.0.16
|
specifier: 1.0.18
|
||||||
version: 1.0.16
|
version: 1.0.18
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.9.2
|
specifier: ^5.9.2
|
||||||
version: 5.9.2
|
version: 5.9.2
|
||||||
@@ -179,7 +179,7 @@ importers:
|
|||||||
version: link:../../packages/better-auth
|
version: link:../../packages/better-auth
|
||||||
better-call:
|
better-call:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 1.0.16
|
version: 1.0.18
|
||||||
better-sqlite3:
|
better-sqlite3:
|
||||||
specifier: ^12.2.0
|
specifier: ^12.2.0
|
||||||
version: 12.2.0
|
version: 12.2.0
|
||||||
@@ -626,7 +626,7 @@ importers:
|
|||||||
version: 13.1.2
|
version: 13.1.2
|
||||||
better-call:
|
better-call:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 1.0.16
|
version: 1.0.18
|
||||||
defu:
|
defu:
|
||||||
specifier: ^6.1.4
|
specifier: ^6.1.4
|
||||||
version: 6.1.4
|
version: 6.1.4
|
||||||
@@ -885,7 +885,7 @@ importers:
|
|||||||
version: link:../better-auth
|
version: link:../better-auth
|
||||||
better-call:
|
better-call:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 1.0.16
|
version: 1.0.18
|
||||||
express:
|
express:
|
||||||
specifier: ^5.1.0
|
specifier: ^5.1.0
|
||||||
version: 5.1.0
|
version: 5.1.0
|
||||||
@@ -901,7 +901,7 @@ importers:
|
|||||||
version: link:../better-auth
|
version: link:../better-auth
|
||||||
better-call:
|
better-call:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 1.0.16
|
version: 1.0.18
|
||||||
stripe:
|
stripe:
|
||||||
specifier: ^18.5.0
|
specifier: ^18.5.0
|
||||||
version: 18.5.0(@types/node@24.3.0)
|
version: 18.5.0(@types/node@24.3.0)
|
||||||
@@ -5783,8 +5783,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
|
resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
|
|
||||||
better-call@1.0.16:
|
better-call@1.0.18:
|
||||||
resolution: {integrity: sha512-42dgJ1rOtc0anOoxjXPOWuel/Z/4aeO7EJ2SiXNwvlkySSgjXhNjAjTMWa8DL1nt6EXS3jl3VKC3mPsU/lUgVA==}
|
resolution: {integrity: sha512-Ojyck3P3fs/egBmCW50tvfbCJorNV5KphfPOKrkCxPfOr8Brth1ruDtAJuhHVHEUiWrXv+vpEgWQk7m7FzhbbQ==}
|
||||||
|
|
||||||
better-opn@3.0.2:
|
better-opn@3.0.2:
|
||||||
resolution: {integrity: sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==}
|
resolution: {integrity: sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==}
|
||||||
@@ -18098,7 +18098,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
safe-buffer: 5.1.2
|
safe-buffer: 5.1.2
|
||||||
|
|
||||||
better-call@1.0.16:
|
better-call@1.0.18:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@better-fetch/fetch': 1.1.18
|
'@better-fetch/fetch': 1.1.18
|
||||||
rou3: 0.5.1
|
rou3: 0.5.1
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ catalogs:
|
|||||||
react: 19.1.1
|
react: 19.1.1
|
||||||
react-dom: 19.1.1
|
react-dom: 19.1.1
|
||||||
catalog:
|
catalog:
|
||||||
"better-call": "1.0.16"
|
"better-call": "1.0.18"
|
||||||
"@better-fetch/fetch": "^1.1.18"
|
"@better-fetch/fetch": "^1.1.18"
|
||||||
"unbuild": "^3.6.1"
|
"unbuild": "^3.6.1"
|
||||||
"typescript": "^5.9.2"
|
"typescript": "^5.9.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user