Skip to content

Commit

Permalink
UBERF-8603: Fix memory leak (#7229)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo authored Nov 24, 2024
1 parent ea7d82d commit aea704f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import core, {
WithTx,
WorkspaceEvent,
checkMixinKey,
clone,
findProperty,
generateId,
getObjectValue,
Expand Down Expand Up @@ -352,12 +353,13 @@ export class LiveQuery implements WithTx, Client {
callback: { callback: (result: FindResult<T>) => void, callbackId: string } | undefined,
options?: FindOptions<T>
): Query {
const _query: DocumentQuery<T> = clone(query)
const localResult = this.refs.findFromDocs(_class, query, options)
const result = localResult != null ? Promise.resolve(localResult) : this.client.findAll(_class, query, options)
const q: Query = {
id: ++this.queryCounter,
_class,
query,
query: _query,
result: result.then((docs) => new ResultArray(docs, this.getHierarchy())),
total: 0,
options: options as FindOptions<Doc>,
Expand Down
3 changes: 2 additions & 1 deletion server/postgres/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,12 @@ abstract class PostgresAdapterBase implements DbAdapter {
private buildQuery<T extends Doc>(
_class: Ref<Class<T>>,
baseDomain: string,
query: DocumentQuery<T>,
_query: DocumentQuery<T>,
joins: JoinProps[],
options?: ServerFindOptions<T>
): string {
const res: string[] = []
const query = { ..._query }
res.push(`${baseDomain}."workspaceId" = '${this.workspaceId.name}'`)
if (options?.skipClass !== true) {
query._class = this.fillClass(_class, query) as any
Expand Down

0 comments on commit aea704f

Please sign in to comment.