diff --git a/.changeset/free-task-identifier-cache.md b/.changeset/free-task-identifier-cache.md new file mode 100644 index 00000000..48ab6618 --- /dev/null +++ b/.changeset/free-task-identifier-cache.md @@ -0,0 +1,8 @@ +--- +"graphile-worker": patch +--- + +Convert an internal cache from using a Map to a WeakMap, fixing a memory leak +impacting users that call Graphile Worker's methods (e.g. `run()`) many times +and provide new options objects each time. Most users will only call `run()` +once so would not be impacted by this. diff --git a/src/taskIdentifiers.ts b/src/taskIdentifiers.ts index eb5d630a..a7392704 100644 --- a/src/taskIdentifiers.ts +++ b/src/taskIdentifiers.ts @@ -16,7 +16,7 @@ interface Cache { lastStr: string | Promise; lastDigest: TaskDetails | Promise; } -const cacheByOptions = new Map(); +const cacheByOptions = new WeakMap(); export function getTaskDetails( compiledSharedOptions: CompiledSharedOptions,