Skip to content

Commit 0ca8710

Browse files
Copilotmtrezza
andcommitted
Improve error messages for double-response protection
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
1 parent e6f4745 commit 0ca8710

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Routers/FunctionsRouter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class FunctionsRouter extends PromiseRouter {
109109
const responseObject = {
110110
success: function (result) {
111111
if (responseSent) {
112-
throw new Error('Response already sent');
112+
throw new Error('Cannot call success() after response has already been sent. Make sure to call success() or error() only once per cloud function execution.');
113113
}
114114
responseSent = true;
115115
const response = {
@@ -124,7 +124,7 @@ export class FunctionsRouter extends PromiseRouter {
124124
},
125125
error: function (message) {
126126
if (responseSent) {
127-
throw new Error('Response already sent');
127+
throw new Error('Cannot call error() after response has already been sent. Make sure to call success() or error() only once per cloud function execution.');
128128
}
129129
responseSent = true;
130130
const error = triggers.resolveError(message);

0 commit comments

Comments
 (0)