Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

tasks:
- init: npm install && npm run build
command: npm run start


5 changes: 5 additions & 0 deletions src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1698,9 +1698,14 @@ class DatabaseController {
return protectedKeys;
}

setTransactionalSession(transactionalSession) {
this._transactionalSession = transactionalSession;
}

createTransactionalSession() {
return this.adapter.createTransactionalSession().then(transactionalSession => {
this._transactionalSession = transactionalSession;
return this._transactionalSession;
});
}

Expand Down
11 changes: 10 additions & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ function RestWrite(config, auth, className, query, data, originalData, clientSDK
// Returns a promise for a {response, status, location} object.
// status and location are optional.
RestWrite.prototype.execute = function () {
if (this.context.transaction) {
this.config.database.setTransactionalSession(this.context.transaction)
}

return Promise.resolve()
.then(() => {
return this.getUserAndRoleACL();
Expand Down Expand Up @@ -167,7 +171,12 @@ RestWrite.prototype.execute = function () {
throw new Parse.Error(Parse.Error.EMAIL_NOT_FOUND, 'User email is not verified.');
}
return this.response;
});
}).finally(() => {
if (this.context.transaction) {
// Ensure isolation even on uncaught errors
this.config.database.setTransactionalSession(null);
}
});;
Comment on lines +174 to +179
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Double semicolon produces an empty statement; remove the extra ;.

Line 179 has });; — the trailing extra semicolon is flagged by static analysis (Biome: noUnreachable). It's a no-op empty statement that should be removed.

Proposed fix
-    }).finally(() => {
-      if (this.context.transaction) {
-        // Ensure isolation even on uncaught errors
-        this.config.database.setTransactionalSession(null);
-      }
-    });;
+    }).finally(() => {
+      if (this.context.transaction) {
+        // Ensure isolation even on uncaught errors
+        this.config.database.setTransactionalSession(null);
+      }
+    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}).finally(() => {
if (this.context.transaction) {
// Ensure isolation even on uncaught errors
this.config.database.setTransactionalSession(null);
}
});;
}).finally(() => {
if (this.context.transaction) {
// Ensure isolation even on uncaught errors
this.config.database.setTransactionalSession(null);
}
});
🧰 Tools
🪛 Biome (2.3.13)

[error] 179-179: This code will never be reached ...

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)

🤖 Prompt for AI Agents
In `@src/RestWrite.js` around lines 174 - 179, Remove the stray empty statement by
deleting the extra semicolon after the finally block; locate the finally()
callback that checks this.context.transaction and calls
this.config.database.setTransactionalSession(null) (appears as "}).;;" in
RestWrite.js) and change it to end with a single semicolon/closing brace only so
there is no double semicolon/empty statement.

};

// Uses the Auth object to get the list of roles, adds the user id
Expand Down
10 changes: 9 additions & 1 deletion src/triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ export function getRequestObject(
triggerType === Types.afterFind
) {
// Set a copy of the context on the request object.
request.context = Object.assign({}, context);
request.context = Object.assign(
{},
context,
{
createTransactionalSession: config.database.createTransactionalSession.bind(config.database),
commitTransactionalSession: config.database.commitTransactionalSession.bind(config.database),
abortTransactionalSession: config.database.abortTransactionalSession.bind(config.database),
}
);
}

if (!auth) {
Expand Down