Skip to content

Commit cfe397e

Browse files
committed
fix(app): make sure resolved val is also not undefined before calling hooks
1 parent c266755 commit cfe397e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/app.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ export function createAppEventHandler(stack: Stack, options: AppOptions) {
151151
const val = await layer.handler(event);
152152

153153
// 5. Try to handle return value
154-
const _response = val === undefined ? undefined : { body: await val };
155-
if (_response !== undefined) {
154+
const _body = val === undefined ? undefined : await val;
155+
if (_body !== undefined) {
156+
const _response = { body: _body };
156157
if (options.onBeforeResponse) {
157158
await options.onBeforeResponse(event, _response);
158159
}
@@ -166,7 +167,7 @@ export function createAppEventHandler(stack: Stack, options: AppOptions) {
166167
// Already handled
167168
if (event.handled) {
168169
if (options.onAfterResponse) {
169-
await options.onAfterResponse(event, _response);
170+
await options.onAfterResponse(event, undefined);
170171
}
171172
return;
172173
}

0 commit comments

Comments
 (0)