Skip to content

Commit eeff6f9

Browse files
Copilotmtrezza
andcommitted
Fix: Always call success() for traditional functions, even when returning undefined
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
1 parent 0ca8710 commit eeff6f9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Routers/FunctionsRouter.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,18 @@ export class FunctionsRouter extends PromiseRouter {
224224
}
225225
})
226226
.then(result => {
227-
// If result is returned and response hasn't already been sent via res.success/res.error
228-
if (result !== undefined && !responseObject._isResponseSent()) {
227+
// For Express-style functions, only send response if not already sent
228+
if (theFunction.length >= 2) {
229+
if (!responseObject._isResponseSent()) {
230+
// If Express-style function returns a value without calling res.success/error
231+
if (result !== undefined) {
232+
success(result);
233+
}
234+
// If no response sent and no value returned, this is an error in user code
235+
// but we don't handle it here to maintain backward compatibility
236+
}
237+
} else {
238+
// For traditional functions, always call success with the result (even if undefined)
229239
success(result);
230240
}
231241
}, error);

0 commit comments

Comments
 (0)