Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
apply review changes for feat: cross-trigger transaction context
  • Loading branch information
Yumcoder-dev committed Jun 11, 2025
commit c23c3648d159bc6f714b42114e94e6065dea896d
7 changes: 6 additions & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,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
14 changes: 9 additions & 5 deletions src/triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,15 @@ export function getRequestObject(
triggerType === Types.afterFind
) {
// Set a copy of the context on the request object.
request.context = Object.assign({
createTransactionalSession: config.database.createTransactionalSession.bind(config.database),
commitTransactionalSession: config.database.commitTransactionalSession.bind(config.database),
abortTransactionalSession: config.database.abortTransactionalSession.bind(config.database),
}, 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